You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2010/05/04 18:59:57 UTC
svn commit: r940955 - in /tapestry/tapestry5/trunk:
src/site/apt/guide/validation.apt
tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
tapestry-core/src/main/java/org/apache/tapestry5/validator/None.java
Author: hlship
Date: Tue May 4 16:59:57 2010
New Revision: 940955
URL: http://svn.apache.org/viewvc?rev=940955&view=rev
Log:
TAP5-1126: Add a new validator, "none", used when overriding the @Validate annotation
Added:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/validator/None.java (with props)
Modified:
tapestry/tapestry5/trunk/src/site/apt/guide/validation.apt
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
Modified: tapestry/tapestry5/trunk/src/site/apt/guide/validation.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/src/site/apt/guide/validation.apt?rev=940955&r1=940954&r2=940955&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/src/site/apt/guide/validation.apt (original)
+++ tapestry/tapestry5/trunk/src/site/apt/guide/validation.apt Tue May 4 16:59:57 2010
@@ -313,6 +313,8 @@ Available Validators
*-----------+-----------------+---------------------------------------------------------------------+-----------------------------------------------------------------------+
| minLength | int | Makes sure that a string value has a minimum length | <<<\<t:textfield value="somefield" validate="minlength=1" /\>>>> |
*-----------+-----------------+---------------------------------------------------------------------+-----------------------------------------------------------------------+
+| none | - | Does nothing (used to override a @Validate annotation) | <<<\<t:textfield value="somefield" validate="none" /\>>>> |
+*-----------+-----------------+---------------------------------------------------------------------+-----------------------------------------------------------------------+
| regexp | pattern | Makes sure that a string value conforms to a given pattern | <<<\<t:textfield value="otherfield" validate="regexp=^[a-z]+$" /\>>>> |
*-----------+-----------------+---------------------------------------------------------------------+-----------------------------------------------------------------------+
| required | - | Makes sure that a string value is not null and not the empty string | <<<\<t:textfield value="name" validate="required" /\>>>> |
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=940955&r1=940954&r2=940955&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java Tue May 4 16:59:57 2010
@@ -120,6 +120,7 @@ import org.apache.tapestry5.validator.Ma
import org.apache.tapestry5.validator.MaxLength;
import org.apache.tapestry5.validator.Min;
import org.apache.tapestry5.validator.MinLength;
+import org.apache.tapestry5.validator.None;
import org.apache.tapestry5.validator.Regexp;
import org.apache.tapestry5.validator.Required;
import org.apache.tapestry5.validator.ValidatorMacro;
@@ -631,7 +632,7 @@ public final class TapestryModule
configuration.add("Retain", new RetainWorker());
configuration.addInstance("Persist", PersistWorker.class);
-
+
configuration.addInstance("DiscardAfter", DiscardAfterWorker.class);
configuration.addInstance("IncludeStylesheet", IncludeStylesheetWorker.class, "after:SetupRender");
@@ -763,6 +764,8 @@ public final class TapestryModule
* <li>min</li>
* <li>max</li>
* <li>regexp</li>
+ * <li>email</li>
+ * <li>none</li>
* </ul>
*/
public static void contributeFieldValidatorSource(MappedConfiguration<String, Validator> configuration)
@@ -774,6 +777,7 @@ public final class TapestryModule
configuration.add("max", new Max());
configuration.add("regexp", new Regexp());
configuration.add("email", new Email());
+ configuration.add("none", new None());
}
/**
Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/validator/None.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/validator/None.java?rev=940955&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/validator/None.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/validator/None.java Tue May 4 16:59:57 2010
@@ -0,0 +1,41 @@
+// Copyright 2010 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.validator;
+
+import org.apache.tapestry5.Field;
+import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.ValidationException;
+import org.apache.tapestry5.ioc.MessageFormatter;
+import org.apache.tapestry5.services.FormSupport;
+
+public class None extends AbstractValidator<Void, Object>
+{
+ public None()
+ {
+ super(Void.class, Object.class, "not-used");
+ }
+
+ /** Does nothing. */
+ public void render(Field field, Void constraintValue, MessageFormatter formatter, MarkupWriter writer,
+ FormSupport formSupport)
+ {
+ }
+
+ /** Does nothing. */
+ public void validate(Field field, Void constraintValue, MessageFormatter formatter, Object value)
+ throws ValidationException
+ {
+ }
+}
Propchange: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/validator/None.java
------------------------------------------------------------------------------
svn:eol-style = native