net.sf.oval
Interface IValidator

All Known Implementing Classes:
Guard, Validator

public interface IValidator

An interface implemented by Validator for easier mocking.

Author:
Sebastian Thomschke

Method Summary
 void assertValid(Object validatedObject)
          validates the field and getter constrains of the given object and throws an ConstraintsViolatedException if any constraint violations are detected
 void assertValidFieldValue(Object validatedObject, Field validatedField, Object fieldValueToValidate)
          Validates the give value against the defined field constraints and throws an ConstraintsViolatedException if any constraint violations are detected.
 List<ConstraintViolation> validate(Object validatedObject)
          validates the field and getter constrains of the given object
 List<ConstraintViolation> validate(Object validatedObject, String... profiles)
          validates the field and getter constrains of the given object
 List<ConstraintViolation> validateFieldValue(Object validatedObject, Field validatedField, Object fieldValueToValidate)
          Validates the give value against the defined field constraints.
 

Method Detail

assertValid

void assertValid(Object validatedObject)
                 throws IllegalArgumentException,
                        ValidationFailedException,
                        ConstraintsViolatedException
validates the field and getter constrains of the given object and throws an ConstraintsViolatedException if any constraint violations are detected

Parameters:
validatedObject - the object to validate, cannot be null
Throws:
ConstraintsViolatedException
ValidationFailedException
IllegalArgumentException - if validatedObject == null

assertValidFieldValue

void assertValidFieldValue(Object validatedObject,
                           Field validatedField,
                           Object fieldValueToValidate)
                           throws IllegalArgumentException,
                                  ValidationFailedException,
                                  ConstraintsViolatedException
Validates the give value against the defined field constraints and throws an ConstraintsViolatedException if any constraint violations are detected.

Parameters:
validatedObject - the object to validate, cannot be null
validatedField - the field to validate, cannot be null
Throws:
IllegalArgumentException - if validatedObject == null or field == null
ConstraintsViolatedException
ValidationFailedException

validate

List<ConstraintViolation> validate(Object validatedObject)
                                   throws IllegalArgumentException,
                                          ValidationFailedException
validates the field and getter constrains of the given object

Parameters:
validatedObject - the object to validate, cannot be null
Returns:
a list with the detected constraint violations. if no violations are detected an empty list is returned
Throws:
ValidationFailedException
IllegalArgumentException - if validatedObject == null

validate

List<ConstraintViolation> validate(Object validatedObject,
                                   String... profiles)
                                   throws IllegalArgumentException,
                                          ValidationFailedException
validates the field and getter constrains of the given object

Parameters:
validatedObject - the object to validate, cannot be null
profiles - constraint profiles to validate against, by default the globally enabled profiles are used that.
Returns:
a list with the detected constraint violations. if no violations are detected an empty list is returned
Throws:
ValidationFailedException
IllegalArgumentException - if validatedObject == null

validateFieldValue

List<ConstraintViolation> validateFieldValue(Object validatedObject,
                                             Field validatedField,
                                             Object fieldValueToValidate)
                                             throws IllegalArgumentException,
                                                    ValidationFailedException
Validates the give value against the defined field constraints.

Returns:
a list with the detected constraint violations. if no violations are detected an empty list is returned
Throws:
IllegalArgumentException - if validatedObject == null or validatedField == null
ValidationFailedException


Copyright © 2005–2015 The OVal Development Team. All rights reserved.