class Doctrine_Validator extends Doctrine_Locator_Injectable (View source)

This class is responsible for performing all validations on record properties

Properties

protected Doctrine_Locator $_locator from Doctrine_Locator_Injectable
protected array $_resources from Doctrine_Locator_Injectable
static protected Doctrine_Null $_null from Doctrine_Locator_Injectable

Methods

setLocator(Doctrine_Locator $locator)

setLocator this method can be used for setting the locator object locally

getLocator()

getLocator returns the locator associated with this object

mixed
locate(string $name)

locate locates a resource by given name and returns it

bind($name, $resource)

bind binds a resource to a name

static void
initNullObject(Doctrine_Null $null)

initNullObject initializes the null object

static Doctrine_Null
getNullObject()

getNullObject returns the null object associated with this object

static Doctrine_Validator_Interface
getValidator(string $name)

Get a validator instance for the passed $name

void
validateRecord(Doctrine_Record $record)

Validates a given record and saves possible errors in Doctrine_Validator::$stack

static boolean
validateLength(string $value, string $type, string $maximumLength)

Validates the length of a field.

static integer
getStringLength(string $string)

Get length of passed string. Will use multibyte character functions if they exist

boolean
hasErrors()

Whether or not errors exist on this validator

static boolean
isValidType(mixed $var, string $type)

Validate the type of the passed variable

Details

Doctrine_Locator_Injectable setLocator(Doctrine_Locator $locator)

setLocator this method can be used for setting the locator object locally

Parameters

Doctrine_Locator $locator the locator object

Return Value

Doctrine_Locator_Injectable this instance

Doctrine_Locator getLocator()

getLocator returns the locator associated with this object

if there are no locator locally associated then this method tries to fetch the current global locator

Return Value

Doctrine_Locator

mixed locate(string $name)

locate locates a resource by given name and returns it

if the resource cannot be found locally this method tries to use the global locator for finding the resource

Parameters

string $name the name of the resource

Return Value

mixed the located resource

Exceptions

Doctrine_Locator_Exception if the resource could not be found

See also

Doctrine_Locator::locate

Doctrine_Locator bind($name, $resource)

bind binds a resource to a name

Parameters

$name
$resource

Return Value

Doctrine_Locator this object

static void initNullObject(Doctrine_Null $null)

initNullObject initializes the null object

Parameters

Doctrine_Null $null

Return Value

void

static Doctrine_Null getNullObject()

getNullObject returns the null object associated with this object

Return Value

Doctrine_Null

static Doctrine_Validator_Interface getValidator(string $name)

Get a validator instance for the passed $name

Parameters

string $name Name of the validator or the validator class name

Return Value

Doctrine_Validator_Interface $validator

void validateRecord(Doctrine_Record $record)

Validates a given record and saves possible errors in Doctrine_Validator::$stack

Parameters

Doctrine_Record $record

Return Value

void

static boolean validateLength(string $value, string $type, string $maximumLength)

Validates the length of a field.

Parameters

string $value Value to validate
string $type Type of field being validated
string $maximumLength Maximum length allowed for the column

Return Value

boolean $success True/false for whether the value passed validation

static integer getStringLength(string $string)

Get length of passed string. Will use multibyte character functions if they exist

Parameters

string $string

Return Value

integer $length

boolean hasErrors()

Whether or not errors exist on this validator

Return Value

boolean True/false for whether or not this validate instance has error

static boolean isValidType(mixed $var, string $type)

Validate the type of the passed variable

Parameters

mixed $var Variable to validate
string $type Type of the variable expected

Return Value

boolean