velosurf.validation
Class OneOf

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

public class OneOf
extends FieldConstraint

An enumeration constraint. Syntax is:

    <column one-of="value1,value2,value3..."/>
  

Or:

     <column>
       <one-of [message="error-message"]>
         <value>value1</value>
         <value>value2</value>
         <value>value3</value>
         ...
       </one-of>
     </column>
   

Note: this constraint is not meant to replace an internal SQL enumeration constraint clause in the database, since it cannot be made sure that complex updates will respect this constraint.

Author:
Claude Brisson

Field Summary
protected  java.util.List _values
           
 
Fields inherited from class velosurf.validation.FieldConstraint
_message
 
Constructor Summary
OneOf(java.util.List values)
          Constructor.
 
Method Summary
 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

_values

protected java.util.List _values
Constructor Detail

OneOf

public OneOf(java.util.List values)
Constructor.

Parameters:
values - the list of possible values
Method Detail

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 among the expected values

toString

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


~ooOoo~