velosurf.validation
Class Length

java.lang.Object
  extended by velosurf.validation.FieldConstraint
      extended by velosurf.validation.Length

public class Length
extends FieldConstraint

A string length constraint. Syntax is:

    <column min-len="min" max-len="max"/>
  

where you donnot need to specify both min-len and max-len.

Or:

   <column>
     <min-len value="min-value" [message="error-message"]>
     <max-len value="max-value" [message="error-message"]>
   </column>
 

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  int maxLen
          max length.
private  int minLen
          min lmength.
 
Constructor Summary
Length(int minLen, int maxLen)
          Constructor.
 
Method Summary
 void setMaxLength(int maxLen)
          Maximum length setter.
 void setMinLength(int minLen)
          Min length setter.
 java.lang.String toString()
          return a string representation for this constraint.
 boolean validate(java.lang.Object data)
          Validate data against this constraint.
 
Methods inherited from class velosurf.validation.FieldConstraint
getMessage, setMessage, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

minLen

private int minLen
min lmength.


maxLen

private int maxLen
max length.

Constructor Detail

Length

public Length(int minLen,
              int maxLen)
Constructor.

Parameters:
minLen - the minimum length allowed (inclusive)
maxLen - the maximum length allowed (inclusive)
Method Detail

setMinLength

public void setMinLength(int minLen)
Min length setter.

Parameters:
minLen - minimum length

setMaxLength

public void setMaxLength(int maxLen)
Maximum length setter.

Parameters:
maxLen - maximum length

validate

public boolean validate(java.lang.Object data)
Validate data against this constraint.

Overrides:
validate in class FieldConstraint
Parameters:
data - data to validate
Returns:
whether data is valid

toString

public java.lang.String toString()
return a string representation for this constraint.

Overrides:
toString in class java.lang.Object
Returns:
string


~ooOoo~