TYPO3  7.6
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GenericObjectValidator Class Reference
Inheritance diagram for GenericObjectValidator:
AbstractValidator ObjectValidatorInterface ValidatorInterface ValidatorInterface CollectionValidator

Public Member Functions

 validate ($value)
 
 canValidate ($object)
 
 addPropertyValidator ($propertyName, ValidatorInterface $validator)
 
 getPropertyValidators ($propertyName=null)
 
 setValidatedInstancesContainer (\SplObjectStorage $validatedInstancesContainer)
 
- Public Member Functions inherited from AbstractValidator
 __construct (array $options=array())
 
 validate ($value)
 
 getOptions ()
 

Protected Member Functions

 getPropertyValue ($object, $propertyName)
 
 isValid ($object)
 
 isValidatedAlready ($object)
 
- Protected Member Functions inherited from AbstractValidator
 isValid ($value)
 
 addError ($message, $code, array $arguments=array(), $title= '')
 
 isEmpty ($value)
 
 translateErrorMessage ($translateKey, $extensionName, $arguments=array())
 

Protected Attributes

 $propertyValidators = array()
 
 $validatedInstancesContainer
 
- Protected Attributes inherited from AbstractValidator
 $acceptsEmptyValues = true
 
 $supportedOptions = array()
 
 $options = array()
 
 $result
 

Detailed Description

A generic object validator which allows for specifying property validators

Definition at line 22 of file GenericObjectValidator.php.

Member Function Documentation

addPropertyValidator (   $propertyName,
ValidatorInterface  $validator 
)

Adds the given validator for validation of the specified property.

Parameters
string$propertyNameName of the property to validate
ValidatorInterface$validatorThe property validator
Returns
void

Definition at line 136 of file GenericObjectValidator.php.

canValidate (   $object)

Checks the given object can be validated by the validator implementation

Parameters
mixed$objectThe object to be checked
Returns
bool TRUE if the given value is an object

Definition at line 123 of file GenericObjectValidator.php.

getPropertyValidators (   $propertyName = null)

Returns all property validators - or only validators of the specified property

Parameters
string$propertyNameName of the property to return validators for
Returns
array An array of validators

Definition at line 168 of file GenericObjectValidator.php.

References GenericObjectValidator\$propertyValidators.

getPropertyValue (   $object,
  $propertyName 
)
protected

Load the property value to be used for validation.

In case the object is a doctrine proxy, we need to load the real instance first.

Parameters
object$object
string$propertyName
Returns
mixed

Definition at line 60 of file GenericObjectValidator.php.

References ObjectAccess\getProperty(), and ObjectAccess\isPropertyGettable().

Referenced by GenericObjectValidator\isValid().

isValid (   $object)
protected

Checks if the given value is valid according to the property validators.

Parameters
mixed$objectThe value that should be validated
Returns
void

Definition at line 108 of file GenericObjectValidator.php.

References GenericObjectValidator\getPropertyValue().

Referenced by GenericObjectValidator\validate().

isValidatedAlready (   $object)
protected
Parameters
object$object
Returns
bool

Definition at line 148 of file GenericObjectValidator.php.

Referenced by GenericObjectValidator\validate(), and CollectionValidator\validate().

setValidatedInstancesContainer ( \SplObjectStorage  $validatedInstancesContainer)

Allows to set a container to keep track of validated instances.

Parameters
\SplObjectStorage$validatedInstancesContainerA container to keep track of validated instances
Returns
void

Implements ObjectValidatorInterface.

Definition at line 189 of file GenericObjectValidator.php.

References GenericObjectValidator\$validatedInstancesContainer.

validate (   $value)

Checks if the given value is valid according to the validator, and returns the Error Messages object which occurred.

Parameters
mixed$valueThe value that should be validated
Returns

Implements ValidatorInterface.

Definition at line 37 of file GenericObjectValidator.php.

References AbstractValidator\$result, AbstractValidator\addError(), elseif, AbstractValidator\isEmpty(), GenericObjectValidator\isValid(), and GenericObjectValidator\isValidatedAlready().

Member Data Documentation

$propertyValidators = array()
protected
$validatedInstancesContainer
protected