wicket.markup.html.form.validation
Class NumberValidator

java.lang.Object
  extended by wicket.markup.html.form.validation.AbstractValidator
      extended by wicket.markup.html.form.validation.NumberValidator
All Implemented Interfaces:
java.io.Serializable, IValidator

public abstract class NumberValidator
extends AbstractValidator

A validator for numbers. See the static factory methods to make range/minimum or maximum validators for doubles or longs

Author:
Jonathan Locke, Johan Compagner
See Also:
Serialized Form

Field Summary
static NumberValidator NEGATIVE
          A validatior for testing if it is a positive number value
static NumberValidator POSITIVE
          A validatior for testing if it is a positive number value
 
Constructor Summary
NumberValidator()
           
 
Method Summary
static NumberValidator maximum(double maximum)
          Gets a Double range validator to check if an integer value is smaller then the given maximum value.
static NumberValidator maximum(long maximum)
          Gets a Integer range validator to check if an integer value is smaller then the given maximum value.
static NumberValidator minimum(double minimum)
          Gets a Double minimum validator to check if a integer value is greater then the given minimum value.
static NumberValidator minimum(long minimum)
          Gets a Integer minimum validator to check if a integer value is greater then the given minimum value.
abstract  void onValidate(FormComponent formComponent, java.lang.Number value)
          Subclasses should override this method to validate the string value for a component.
static NumberValidator range(double minimum, double maximum)
          Gets a Double range validator to check if a number is between the mininum and maximum value.
static NumberValidator range(long minimum, long maximum)
          Gets a Integer range validator to check if a number is between the mininum and maximum value.
 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
 

Field Detail

POSITIVE

public static final NumberValidator POSITIVE
A validatior for testing if it is a positive number value


NEGATIVE

public static final NumberValidator NEGATIVE
A validatior for testing if it is a positive number value

Constructor Detail

NumberValidator

public NumberValidator()
Method Detail

range

public static NumberValidator range(long minimum,
                                    long maximum)
Gets a Integer range validator to check if a number is between the mininum and maximum value. If that is not the case then an error message will be generated with the key "NumberValidator.range" and the messages keys that can be used are:

Parameters:
minimum - The minimum value.
maximum - The maximum value.
Returns:
The NumberValidator

minimum

public static NumberValidator minimum(long minimum)
Gets a Integer minimum validator to check if a integer value is greater then the given minimum value. If that is not the case then an error message will be generated with the key "NumberValidator.minimum" and the messages keys that can be used are:

Parameters:
minimum - The minimum value.
Returns:
The NumberValidator

maximum

public static NumberValidator maximum(long maximum)
Gets a Integer range validator to check if an integer value 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 value.
Returns:
The NumberValidator

range

public static NumberValidator range(double minimum,
                                    double maximum)
Gets a Double range validator to check if a number is between the mininum and maximum value. If that is not the case then an error message will be generated with the key "NumberValidator.range" and the messages keys that can be used are:

Parameters:
minimum - The minimum value.
maximum - The maximum value.
Returns:
The NumberValidator

minimum

public static NumberValidator minimum(double minimum)
Gets a Double minimum validator to check if a integer value is greater then the given minimum value. If that is not the case then an error message will be generated with the key "NumberValidator.minimum" and the messages keys that can be used are:

Parameters:
minimum - The minimum value.
Returns:
The NumberValidator

maximum

public static NumberValidator maximum(double maximum)
Gets a Double range validator to check if an integer value 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 value.
Returns:
The NumberValidator

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.Number 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.