wicket.markup.html.form.validation
Class StringValidator

java.lang.Object
  extended by wicket.markup.html.form.validation.AbstractValidator
      extended by wicket.markup.html.form.validation.StringValidator
All Implemented Interfaces:
java.io.Serializable, IValidator
Direct Known Subclasses:
CustomValidator, IntegerValidator, PatternValidator, TypeValidator

public abstract class StringValidator
extends AbstractValidator

A validator for strings that can be used for subclassing or use one of the static factory methods to get the default string validators as range, maximum or minimum.

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

Constructor Summary
StringValidator()
           
 
Method Summary
static StringValidator exactLength(int length)
          Gets a String exact length validator to check if a string length is exactly the same as the given value If that is not the case then an error message will be generated with the key "StringValidator.exact" and the messages keys that can be used are: ${exact}: the maximum length ${length}: the length of the user input ${input}: the input the user did give ${name}: the name of the component that failed ${label}: the label of the component - either comes from FormComponent.labelModel or resource key [form-id].[form-component-id] in that order
static StringValidator lengthBetween(int minimum, int maximum)
          Gets a String range validator to check if a string length is between min and max.
static StringValidator maximumLength(int maximum)
          Gets a String maximum validator to check if a string length is smaller then the given maximum value.
static StringValidator minimumLength(int minimum)
          Gets a String minimum validator to check if a string length is greater then the given minimum value.
abstract  void onValidate(FormComponent formComponent, java.lang.String value)
          Subclasses should override this method to validate the string value for a component.
 void validate(FormComponent formComponent)
           Instead of subclassing IValidator, you should use one of the existing validators, which cover a huge number of cases, or if none satisfies your need, subclass one of the Type validators like StringValidator, NumberValidator or DateValidator
 
Methods inherited from class wicket.markup.html.form.validation.AbstractValidator
error, error, error, error, messageModel, resourceKey
 
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

lengthBetween

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

Parameters:
minimum - The minimum length of the string.
maximum - The maximum length of the string.
Returns:
The StringValidator

minimumLength

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

Parameters:
minimum - The minimum length of the string.
Returns:
The StringValidator

maximumLength

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

Parameters:
maximum - The maximum length of the string.
Returns:
The StringValidator

exactLength

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

Parameters:
length - The required length of the string.
Returns:
The StringValidator

validate

public void validate(FormComponent formComponent)
Description copied from interface: IValidator

Instead of subclassing IValidator, you should use one of the existing validators, which cover a huge number of cases, or if none satisfies your need, subclass one of the Type validators like StringValidator, NumberValidator or DateValidator

Validates the given input. The input corresponds to the input from the request for a component.

Parameters:
formComponent - Component to validate
See Also:
IValidator.validate(wicket.markup.html.form.FormComponent)

onValidate

public abstract void onValidate(FormComponent formComponent,
                                java.lang.String value)
Subclasses should override this method to validate the string value for a component.

Parameters:
formComponent - form component
value - The string value to validate


Copyright © 2004-2007 Wicket developers. All Rights Reserved.