Packageorg.granite.validation
Interfacepublic interface IConstraint
ImplementorsBaseConstraint

The interface that all constraint validors must implement.



Public Properties
 PropertyDefined by
  factory : ValidatorFactory
[read-only] The ValidatorFactory passed to the initialized function.
IConstraint
  groups : Array
[read-only] The processing groups with which this constraint is associated as an array of Class.
IConstraint
  message : String
[read-only] The error message associated with this constraint.
IConstraint
  payload : Array
[read-only] The payload with which this constraint is associated as an array of String.
IConstraint
  properties : Array
[read-only] The properties with which this constraint is associated as an array of String (only for class-level constraints that deal with one or more properties, in order to figure out where error messages should be displayed when this constraint fails).
IConstraint
Public Methods
 MethodDefined by
  
initialize(annotation:Annotation, factory:ValidatorFactory):void
Initialize this constraint, according to the supplied annotation parameters.
IConstraint
  
validate(value:*):String
Validate the value parameter, according to this constraint specification.
IConstraint
Property detail
factoryproperty
factory:ValidatorFactory  [read-only]

The ValidatorFactory passed to the initialized function.

Implementation
    public function get factory():ValidatorFactory
groupsproperty 
groups:Array  [read-only]

The processing groups with which this constraint is associated as an array of Class.

Implementation
    public function get groups():Array
messageproperty 
message:String  [read-only]

The error message associated with this constraint.

Implementation
    public function get message():String
payloadproperty 
payload:Array  [read-only]

The payload with which this constraint is associated as an array of String.

Implementation
    public function get payload():Array
propertiesproperty 
properties:Array  [read-only]

The properties with which this constraint is associated as an array of String (only for class-level constraints that deal with one or more properties, in order to figure out where error messages should be displayed when this constraint fails).

Implementation
    public function get properties():Array
Method detail
initialize()method
public function initialize(annotation:Annotation, factory:ValidatorFactory):void

Initialize this constraint, according to the supplied annotation parameters.

The org.granite.validation.BaseConstraint implementation of this method throws an Error and must be overridden in inherited classes.

Parameters
annotation:Annotation — the anntotation defining this constraint.
 
factory:ValidatorFactory

Throws
ConstraintDefinitionError — if a required argument is missing, if an argument value isn't of the expected type or if an unknown argument is present.

See also

validate()method 
public function validate(value:*):String

Validate the value parameter, according to this constraint specification.

The org.granite.validation.BaseConstraint implementation of this method throws an Error and must be overridden in inherited classes.

Parameters
value:* — the value to be validated.

Returns
Stringnull if the supplied value is valid, an error message key otherwise.

Throws
ConstraintExecutionError — if the value parameter is an instance of an unsupported type according to this constraint specification.

See also