velosurf.validation
Class Range
java.lang.Object
velosurf.validation.FieldConstraint
velosurf.validation.Range
public class Range
- extends FieldConstraint
A type and range constraint on numbers. Syntax is:
<column [type="integer"] [min="min"] [max="max"]/>
where you donnot need to specify both min and max.
Or:
<integer|number [min="min-value"] [max="max-value"] [message="error-message"] />
Note: this constraint is not meant to replace an internal SQL constraint in the database,
since it cannot be made sure that complex updates will respect this constraint.
- Author:
- Claude Brisson
|
Field Summary |
private boolean |
_integer
|
private static java.util.regex.Pattern |
_intPattern
|
private java.lang.Number |
_max
|
private java.lang.Number |
_min
|
|
Constructor Summary |
Range()
Constructor. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
_min
private java.lang.Number _min
_max
private java.lang.Number _max
_integer
private boolean _integer
_intPattern
private static java.util.regex.Pattern _intPattern
Range
public Range()
- Constructor.
setInteger
public void setInteger(boolean integer)
setMin
public void setMin(java.lang.Number min)
setMax
public void setMax(java.lang.Number max)
validate
public boolean validate(java.lang.Object data)
throws java.sql.SQLException
- Overrides:
validate in class FieldConstraint
- Parameters:
data - the data to be validated
- Returns:
- true if data is in the expected range and type
- Throws:
java.sql.SQLException
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object
~ooOoo~