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.

instead of one.

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
protected  int _maxLen
           
protected  int _minLen
           
 
Fields inherited from class velosurf.validation.FieldConstraint
_message
 
Constructor Summary
Length(int minLen, int maxLen)
          Constructor.
Length(int minLen, int maxLen, java.lang.String msg)
          Constructor.
 
Method Summary
 void setMaxLength(int maxLen)
           
 void setMinLength(int minLen)
           
 java.lang.String toString()
           
 boolean validate(java.lang.Object data)
           
 
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

protected int _minLen

_maxLen

protected int _maxLen
Constructor Detail

Length

public Length(int minLen,
              int maxLen)
Constructor.

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

Length

public Length(int minLen,
              int maxLen,
              java.lang.String msg)
Constructor.

Parameters:
minLen - the minimum length allowed (inclusive)
maxLen - the maximum length allowed (inclusive)
msg - a string like "is not of the proper length"
Method Detail

setMinLength

public void setMinLength(int minLen)

setMaxLength

public void setMaxLength(int maxLen)

validate

public boolean validate(java.lang.Object data)
Overrides:
validate in class FieldConstraint
Parameters:
data - the data to be validated
Returns:
true if data is a string of the expected length

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


~ooOoo~