org.apache.wicket.validation.validator
Class StringValidator

java.lang.Object
  extended by org.apache.wicket.behavior.Behavior
      extended by org.apache.wicket.validation.validator.AbstractValidator<java.lang.String>
          extended by org.apache.wicket.validation.validator.StringValidator
All Implemented Interfaces:
java.io.Serializable, IClusterable, IComponentAwareEventSink, IComponentAwareHeaderContributor, INullAcceptingValidator<java.lang.String>, IValidator<java.lang.String>
Direct Known Subclasses:
PatternValidator, RfcCompliantEmailAddressValidator, StringValidator.ExactLengthValidator, StringValidator.LengthBetweenValidator, StringValidator.MaximumLengthValidator, StringValidator.MinimumLengthValidator

public abstract class StringValidator
extends AbstractValidator<java.lang.String>

Validator for checking String lengths. Usually this validator is used through the static factory methods, but it and its inner classes can also be subclassed directly.

Since:
1.2.6
Author:
Jonathan Locke, Johan Compagner, Igor Vaynberg (ivaynberg)
See Also:
Serialized Form

Nested Class Summary
static class StringValidator.ExactLengthValidator
          Validator for checking if the length of a String is exactly the specified length.
static class StringValidator.LengthBetweenValidator
          Validator for checking if the length of a String is within the specified range.
static class StringValidator.MaximumLengthValidator
          Validator for checking if the length of a String meets the maximum length requirement.
static class StringValidator.MinimumLengthValidator
          Validator for checking if the length of a String meets the minimum length requirement.
 
Constructor Summary
StringValidator()
           
 
Method Summary
static StringValidator exactLength(int length)
          Gets a String exact length validator for checking if a string length is exactly the same as the given length value.
static StringValidator lengthBetween(int minimum, int maximum)
          Gets a String range validator for checking if a string length falls between the minimum and and maximum lengths.
static StringValidator maximumLength(int maximum)
          Gets a String maximum validator for checking if a string length is smaller than the given maximum value.
static StringValidator minimumLength(int minimum)
          Gets a String minimum validator for checking if a string length is greater than the given minimum value.
 
Methods inherited from class org.apache.wicket.validation.validator.AbstractValidator
error, error, error, error, onValidate, resourceKey, validate, validateOnNullValue, variablesMap
 
Methods inherited from class org.apache.wicket.behavior.Behavior
afterRender, beforeRender, bind, canCallListenerInterface, detach, getStatelessHint, isEnabled, isTemporary, onComponentTag, onConfigure, onEvent, onException, renderHead, unbind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringValidator

public StringValidator()
Method Detail

exactLength

public static StringValidator exactLength(int length)
Gets a String exact length validator for checking if a string length is exactly the same as the given length value. If that is not the case, then an error message will be generated with the key "StringValidator.exact". The message keys that can be used are:

Parameters:
length - the required length of the string
Returns:
the requested StringValidator

lengthBetween

public static StringValidator lengthBetween(int minimum,
                                            int maximum)
Gets a String range validator for checking if a string length falls between the minimum and and maximum lengths. If that is not the case, then an error message will be generated with the key "StringValidator.range". The message keys that can be used are:

Parameters:
minimum - the minimum length of the string
maximum - the maximum length of the string
Returns:
the requested StringValidator

maximumLength

public static StringValidator maximumLength(int maximum)
Gets a String maximum validator for checking if a string length is smaller than the given maximum value. If that is not the case, then an error message will be generated with the key "StringValidator.maximum". The message keys that can be used are:

Parameters:
maximum - the maximum length of the string
Returns:
the requested StringValidator

minimumLength

public static StringValidator minimumLength(int minimum)
Gets a String minimum validator for checking if a string length is greater than the given minimum value. If that is not the case, then an error message will be generated with the key "StringValidator.minimum". The message keys that can be used are:

Parameters:
minimum - the minimum length of the string
Returns:
the requested StringValidator


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.