Packageorg.granite.validation
Classpublic class BaseConstraint
ImplementsIConstraint
SubclassesAssertFalse, AssertTrue, DecimalMax, DecimalMin, Digits, Future, Max, Min, NotNull, Null, Past, Pattern, Size

A basic class that simplifies IConstraint implementations. See standard constraint implementations for usage.



Public Properties
 PropertyDefined by
  factory : ValidatorFactory
[read-only] The ValidatorFactory passed to the initialized function.
BaseConstraint
  groups : Array
[read-only] The processing groups with which this constraint is associated as an array of Class.
BaseConstraint
  message : String
[read-only] The error message associated with this constraint.
BaseConstraint
  payload : Array
[read-only] The payload with which this constraint is associated as an array of String.
BaseConstraint
  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).
BaseConstraint
Protected Properties
 PropertyDefined by
  _factory : ValidatorFactory
Direct access (protected) to the ValidatorFactory instance passed to the initialized function.
BaseConstraint
  _groups : Array
Direct access (protected) to the groups defined for this constraint.
BaseConstraint
  _message : String
Direct access (protected) to the message key defined for this constraint.
BaseConstraint
  _payload : Array
Direct access (protected) to the payload defined for this constraint.
BaseConstraint
  _properties : Array
Direct access (protected) to the properties defined for this constraint.
BaseConstraint
Public Methods
 MethodDefined by
  
initialize(annotation:Annotation, factory:ValidatorFactory):void
Initialize this constraint, according to the supplied annotation parameters.
BaseConstraint
  
validate(value:*):String
Validate the value parameter, according to this constraint specification.
BaseConstraint
Protected Methods
 MethodDefined by
  
[static] Creates a definition of the standard message annotation argument with the supplied string.
BaseConstraint
  
internalInitialize(factory:ValidatorFactory, annotation:Annotation, defaultMessage:String, parameterDefinitions:Array = null):Dictionary
Parse constraint parameters according to the annotation arguments, initialize the message, groups and payload properties and return a Dictionary that contains all parsed values.
BaseConstraint
Protected Constants
 ConstantDefined by
  BOOLEAN_TYPES : Array
[static] An array of boolean types: [Boolean] (used when checking the value type of a constraint annotation argument).
BaseConstraint
  DATE_TYPES : Array
[static] An array of date types: [Date] (used when checking the value type of a constraint annotation argument).
BaseConstraint
  GROUPS_PARAMETER : ParameterDefinition
[static] The definition of the standard groups constraint annotation argument, as an optional array of Class names.
BaseConstraint
  NUMBER_STRING_TYPES : Array
[static] An array of numeric or string types: [BigDecimal, BigInteger, Long, Number, int, uint String] (used when checking the value type of a constraint annotation argument).
BaseConstraint
  PAYLOAD_PARAMETER : ParameterDefinition
[static] The definition of the standard payload constraint annotation argument, as an optional array of Strings.
BaseConstraint
  PROPERTIES_PARAMETER : ParameterDefinition
[static] The definition of the standard properties constraint annotation argument, as an optional array of Strings.
BaseConstraint
  STRING_TYPES : Array
[static] An array of string types: [String] (used when checking the value type of a constraint annotation argument).
BaseConstraint
Property detail
_factoryproperty
protected var _factory:ValidatorFactory

Direct access (protected) to the ValidatorFactory instance passed to the initialized function.

See also

factoryproperty 
factory:ValidatorFactory  [read-only]

The ValidatorFactory passed to the initialized function.

Implementation
    public function get factory():ValidatorFactory
_groupsproperty 
protected var _groups:Array

Direct access (protected) to the groups defined for this constraint.

See also

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 
protected var _message:String

Direct access (protected) to the message key defined for this constraint.

See also

messageproperty 
message:String  [read-only]

The error message associated with this constraint.

Implementation
    public function get message():String
_payloadproperty 
protected var _payload:Array

Direct access (protected) to the payload defined for this constraint.

See also

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 
protected var _properties:Array

Direct access (protected) to the properties defined for this constraint.

See also

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
createMessageParameter()method
protected static function createMessageParameter(message:String):ParameterDefinition

Creates a definition of the standard message annotation argument with the supplied string.

Parameters
message:String — the message key used in the returned message ParameterDefinition.

Returns
ParameterDefinition — a new ParameterDefinition for the standard message constraint annotation argument.
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
internalInitialize()method 
protected function internalInitialize(factory:ValidatorFactory, annotation:Annotation, defaultMessage:String, parameterDefinitions:Array = null):Dictionary

Parse constraint parameters according to the annotation arguments, initialize the message, groups and payload properties and return a Dictionary that contains all parsed values.

Parameters
factory:ValidatorFactory — the constraint annotation with its arguments.
 
annotation:Annotation — the default error message for this constraint.
 
defaultMessage:String — an array of ParameterDefinition that contains specific argument definitions for this constraint (excluding message, groups and payload).
 
parameterDefinitions:Array (default = null)

Returns
Dictionary — a Dictionary with parsed arguments.

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.
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.
Constant detail
BOOLEAN_TYPESconstant
protected static const BOOLEAN_TYPES:Array

An array of boolean types: [Boolean] (used when checking the value type of a constraint annotation argument).

See also

DATE_TYPESconstant 
protected static const DATE_TYPES:Array

An array of date types: [Date] (used when checking the value type of a constraint annotation argument).

See also

GROUPS_PARAMETERconstant 
protected static const GROUPS_PARAMETER:ParameterDefinition

The definition of the standard groups constraint annotation argument, as an optional array of Class names.

NUMBER_STRING_TYPESconstant 
protected static const NUMBER_STRING_TYPES:Array

An array of numeric or string types: [BigDecimal, BigInteger, Long, Number, int, uint String] (used when checking the value type of a constraint annotation argument).

See also

PAYLOAD_PARAMETERconstant 
protected static const PAYLOAD_PARAMETER:ParameterDefinition

The definition of the standard payload constraint annotation argument, as an optional array of Strings.

PROPERTIES_PARAMETERconstant 
protected static const PROPERTIES_PARAMETER:ParameterDefinition

The definition of the standard properties constraint annotation argument, as an optional array of Strings.

STRING_TYPESconstant 
protected static const STRING_TYPES:Array

An array of string types: [String] (used when checking the value type of a constraint annotation argument).

See also