|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.stripes.validation.ValidationMetadata
public class ValidationMetadata
Encapsulates the validation metadata for a single property of a single class. Structure is purposely very similar to the @Validate annotation. This class is used internally to store and manipulate validation metadata, the source of which is often validation annotations.
However, since this class is not an annotation it has the added benefits of being able to contain behaviour, being subclassable, and of being able to be instantiated at runtime - i.e. it can contain non-static validation information.
Constructor Summary | |
---|---|
ValidationMetadata(String property)
Constructs a ValidationMetadata object for the specified property. |
|
ValidationMetadata(String property,
Validate validate)
Essentially a copy constructor that constructs a ValidationMetadata object from an @Validate annotation declared on a property. |
Method Summary | |
---|---|
Class<? extends TypeConverter> |
converter()
Returns the overridden TypeConverter if there is one, or null. |
ValidationMetadata |
converter(Class<? extends TypeConverter> converter)
Sets the overridden TypeConveter to use to convert values. |
boolean |
encrypted()
Returns true if the field in question is encrypted. |
ValidationMetadata |
encrypted(boolean encrypted)
Sets the encrypted flag for this field. |
String |
expression()
Returns the overridden TypeConverter if there is one, or null. |
ValidationMetadata |
expression(String expression)
Sets the expression that should be used to validate values. |
String |
getProperty()
Returns the name of the property this validation metadata represents. |
boolean |
ignore()
Returns true if this field should be ignored in binding and validation. |
ValidationMetadata |
ignore(boolean ignore)
Sets whether or not this field should be ignored during binding and validation. |
String |
label()
Get the field label. |
void |
label(String label)
Set the field label. |
Pattern |
mask()
Returns the mask Pattern property values must match, or null if there is none. |
ValidationMetadata |
mask(String mask)
Sets the mask which the String form of the property must match. |
Integer |
maxlength()
Returns the maximum acceptable length for values, or null if there is none. |
ValidationMetadata |
maxlength(Integer maxlength)
Sets the maximum acceptable length for property values. |
Double |
maxvalue()
Returns the maximum acceptable value for numeric properties, or null if there is none. |
ValidationMetadata |
maxvalue(Double maxvalue)
Sets the maximum acceptable value for numeric property values. |
Integer |
minlength()
Returns the minimum acceptable length for values, or null if there is none. |
ValidationMetadata |
minlength(Integer minlength)
Sets the minimum acceptable length for property values. |
Double |
minvalue()
Returns the minimum acceptable value for numeric properties, or null if there is none. |
ValidationMetadata |
minvalue(Double minvalue)
Sets the minimum acceptable value for numeric property values. |
Set<String> |
on()
Returns the set of events for which the field in question is required. |
ValidationMetadata |
on(String... on)
Sets the set of events for which the field in question is required, if it is at all. |
boolean |
required()
Returns true if the field in question is required. |
ValidationMetadata |
required(boolean required)
Sets the required-ness of this field. |
boolean |
requiredOn(String event)
Returns true if the field is required when processing the specified event. |
String |
toString()
Overidden toString() that only outputs the constraints that are specified by the instance of validation metadata (i.e. |
boolean |
trim()
Returns true if the field should be trimmed before validation or type conversion. |
ValidationMetadata |
trim(boolean trim)
Sets the trim flag of this field. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ValidationMetadata(String property)
new ValidationMetadata("username").minlength(5).maxlength(10);
property
- the name of the property to be validated. If the property is a nested
property then the fully path should be included, e.g. user.address.city
public ValidationMetadata(String property, Validate validate)
validate
- Method Detail |
---|
public String getProperty()
public ValidationMetadata encrypted(boolean encrypted)
public boolean encrypted()
public ValidationMetadata required(boolean required)
public boolean required()
public ValidationMetadata trim(boolean trim)
public boolean trim()
public boolean requiredOn(String event)
public ValidationMetadata ignore(boolean ignore)
public boolean ignore()
public ValidationMetadata minlength(Integer minlength)
public Integer minlength()
public ValidationMetadata maxlength(Integer maxlength)
public Integer maxlength()
public ValidationMetadata minvalue(Double minvalue)
public Double minvalue()
public ValidationMetadata maxvalue(Double maxvalue)
public Double maxvalue()
public ValidationMetadata mask(String mask)
public Pattern mask()
public ValidationMetadata converter(Class<? extends TypeConverter> converter)
public Class<? extends TypeConverter> converter()
public ValidationMetadata expression(String expression)
public String expression()
public ValidationMetadata on(String... on)
public Set<String> on()
public void label(String label)
public String label()
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |