it.amattioli.dominate.validation
Interface Validator

Show UML class diagram
All Known Implementing Classes:
ChainedValidator, DefaultValidator, HibernateValidator3Validator

public interface Validator

An object that implements this interface can be used to validate an object. Implementations of the interface should provide a way to set the object to be validated. Tipically the object to be validated will be passed to the validator constructor. The validator can also be used to retrieve validation meta-data.

Author:
andrea

Method Summary
 Constraint getPropertyConstraint(String propertyName, String constraintName)
          Retrieves validation meta-data about a property.
 Collection<Constraint> getPropertyConstraints(String propertyName)
          Retrieves validation meta-data about a property.
 ValidationResult validateBean()
          Check if an object is valid as a whole.
 ValidationResult validateProperty(String propertyName, Object value)
          Check if a value is valid for a property.
 

Method Detail

validateBean

ValidationResult validateBean()
Check if an object is valid as a whole.

Returns:
a ValidationResult object whose type is ValidationResult.ResultType.VALID if the object is valid, otherwise a ValidationResult object whose type is ValidationResult.ResultType.INVALID

validateProperty

ValidationResult validateProperty(String propertyName,
                                  Object value)
Check if a value is valid for a property.

Parameters:
propertyName - the name of the property to be checked
value - the value to be checked
Returns:
a ValidationResult object whose type is ValidationResult.ResultType.VALID if the value is valid for the property, otherwise a ValidationResult object whose type is ValidationResult.ResultType.INVALID

getPropertyConstraints

Collection<Constraint> getPropertyConstraints(String propertyName)
Retrieves validation meta-data about a property.

Parameters:
propertyName - the name of the property
Returns:
a collection of Constraint objects each containing a constraint description

getPropertyConstraint

Constraint getPropertyConstraint(String propertyName,
                                 String constraintName)
Retrieves validation meta-data about a property.

Parameters:
propertyName - the name of the property
constraintName - the name of the constraint to be retrieved
Returns:
the constraint of the given property with the given name if it exists, null otherwise


Copyright © 2011. All Rights Reserved.