Packageorg.granite.validation
Classpublic class GenericValidator
ImplementsIValidator, IVisitor

A generic IValidator implementation. Instances of this class must only be used once.



Public Properties
 PropertyDefined by
  factory : ValidatorFactory
[read-only] The ValidatorFactory instance used in this validator.
GenericValidator
Public Methods
 MethodDefined by
  
Constructs a new GenericValidator instance.
GenericValidator
  
accept(visitable:Visitable):Boolean
Do validation constraint processing on the supplied visitable instance.
GenericValidator
  
validate(bean:Object, groups:Array = null):Array
Validates all constraints on bean.
GenericValidator
  
validateProperty(bean:Object, propertyName:String, groups:Array = null):Array
Validates all constraints placed on the property of bean named propertyName.
GenericValidator
  
validateValue(type:Type, propertyName:String, value:Array, groups:* = null):Array
Validates all constraints placed on the property named propertyName of the class type would the property value be value.
GenericValidator
  
visit(visitable:Visitable):Boolean
Ask the current TraversableResolver if the visitable is cascadable and test if it is bean or collection annotated with [Valid].
GenericValidator
Protected Methods
 MethodDefined by
  
createConstraintViolation(visitable:Visitable, constraint:IConstraint, violation:String):ConstraintViolation
GenericValidator
Property detail
factoryproperty
factory:ValidatorFactory  [read-only]

The ValidatorFactory instance used in this validator.

Implementation
    public function get factory():ValidatorFactory
Constructor detail
GenericValidator()constructor
public function GenericValidator(factory:ValidatorFactory)

Constructs a new GenericValidator instance.

Parameters
factory:ValidatorFactory — the ValidatorFactory to be used for the validation (may not be null).
Method detail
accept()method
public function accept(visitable:Visitable):Boolean

Do validation constraint processing on the supplied visitable instance. This method first ask the current TraversableResolver if this visitable is reachable.

Parameters
visitable:Visitable — the visitable instance to validate.

Returns
Booleantrue if the supplied visitable is reachable, false otherwise.

See also

createConstraintViolation()method 
protected function createConstraintViolation(visitable:Visitable, constraint:IConstraint, violation:String):ConstraintViolation

Parameters
visitable:Visitable
 
constraint:IConstraint
 
violation:String

Returns
ConstraintViolation
validate()method 
public function validate(bean:Object, groups:Array = null):Array

Validates all constraints on bean.

Parameters
bean:Object — the bean to validate.
 
groups:Array (default = null) — an array of groups targeted for validation (default is null, meaning that the Default group will be used).

Returns
Array — an array of ConstraintValidation, possibly empty or null.
validateProperty()method 
public function validateProperty(bean:Object, propertyName:String, groups:Array = null):Array

Validates all constraints placed on the property of bean named propertyName.

Parameters
bean:Object — the bean holding the property to validate.
 
propertyName:String — the property name to validate.
 
groups:Array (default = null) — an array of groups targeted for validation (default is null, meaning that the Default group will be used).

Returns
Array — an array of ConstraintValidation, possibly empty or null.
validateValue()method 
public function validateValue(type:Type, propertyName:String, value:Array, groups:* = null):Array

Validates all constraints placed on the property named propertyName of the class type would the property value be value.

Parameters
type:Type — the bean type holding the property to validate.
 
propertyName:String — the property name to validate.
 
value:Array — the property value to validate.
 
groups:* (default = null) — an array of groups targeted for validation (default is null, meaning that the Default group will be used).

Returns
Array — an array of ConstraintValidation, possibly empty or null.
visit()method 
public function visit(visitable:Visitable):Boolean

Ask the current TraversableResolver if the visitable is cascadable and test if it is bean or collection annotated with [Valid].

Parameters
visitable:Visitable — the visitable instance to be tested for cascading.

Returns
Booleantrue if the supplied visitable should be cascaded, false otherwise.

See also