Arbit - project tracking

Arbit - project tracking

API documentation :: Docs For Class arbitModelValidatorBase

Core::Model::arbitModelValidatorBase

Class arbitModelValidatorBase

Abstract base class for stackable property validators, to be used in model classes.

Abstract base class for stackable property validators, to be used in model classes. The static method create() for validator construction allows direct dereferencing of the configured validor, so that it may be used like the following example shows to validate an array where the values match the defined regular expression.

  1.   $validated = arbitModelArrayValidator::create(
  2.           arbitModelRegexpValidator::create( '(^[a-z]+$)' )
  3.       )->validate( 'some_property', $input, 'array( string )' );

Author(s):
Version:   $Revision: 1236 $
License:   GPL

Descendants

Child Class Description
arbitModelArrayValidator Array validator class
arbitModelSetValidator Set validator class
arbitModelObjectValidator Object validator class
arbitModelIntegerValidator Integer validator class
arbitModelStringValidator String validator class
arbitModelDummyValidator Dummy validator class, for situations where a validator is required, but no validation is needed.

Method Summary

public static void create( )
Create validator.
public void configure( )
Configure validator Method to configure the validator, if it requires configuration at all.
public abstract mixed validate( $name , $value , $expectation )
Validate value Validates the given input. validation constraints and throws a arbitPropertyValidationException exception otherwise.

Methods

create

static void create( )

Create validator.

Create validator. Create a validator object and configure it with the parameters passed to this method. We use a static method for this instead of the common constructor, because calls to constructors do not work with direct dereferencing, which would make the usage of the validator classes more complex. You may pass any number of parameters to the create method, they will all passed through to the configure method of the called validator. For the exact parameters check the documentation of the configure method of the respective validator.

configure

void configure( )

Configure validator Method to configure the validator, if it requires configuration at all.

Configure validator Method to configure the validator, if it requires configuration at all.

Redefined in descendants as:
Method Description
arbitModelArrayValidator::configure() Configure validator The array validator may optionally be configured with an additional validator, which is applied to all array values. validator class no assumptions will be made on the array values. 
arbitModelSetValidator::configure() Configure validator The array validator should be configured with an array, which contains the allowed values. 
arbitModelObjectValidator::configure() Configure validator The object validator will optionally take a class name, which causes the passed objects are checked that they inherit from the specified class. 
arbitModelIntegerValidator::configure() Configure validator The integer validator may optionally assign maximum and minimum values to the given content. 
arbitModelStringValidator::configure() Configure validator The integer validator may optionally assign maximum and minimum values to the given content. 

validate

mixed validate( string $name , mixed $value , string $expectation )

Validate value Validates the given input. validation constraints and throws a arbitPropertyValidationException exception otherwise.

Validate value Validates the given input. Returns the input, when it matches the validation constraints and throws a arbitPropertyValidationException exception otherwise. The name and expectation paramters are used to generate a better user error message. The name should be the name of the property, and the expectation should be a string somehow describing what kind of content was expected from validation.

Parameters:
Name Type Description
$name string
$value mixed
$expectation string
Exceptions:
Type Description
arbitPropertyValue If validation constraints are not met.
Redefined in descendants as:
Method Description
arbitModelArrayValidator::validate() Validate value Validates the given input. validation constraints and throws a arbitPropertyValidationException exception otherwise. 
arbitModelSetValidator::validate() Validate value Validates the given input. validation constraints and throws a arbitPropertyValidationException exception otherwise. 
arbitModelObjectValidator::validate() Validate value Validates the given input. validation constraints and throws a arbitPropertyValidationException exception otherwise. 
arbitModelIntegerValidator::validate() Validate value Validates the given input. validation constraints and throws a arbitPropertyValidationException exception otherwise. 
arbitModelStringValidator::validate() Validate value Validates the given input. validation constraints and throws a arbitPropertyValidationException exception otherwise. 
arbitModelDummyValidator::validate() Validate value Validates the given input. validation constraints and throws a arbitPropertyValidationException exception otherwise. 
Documentation generated on Mon, 05 Apr 2010 14:01:38 +0200 by phpDocumentor 1.4.3