class Validator (View source)

Form validation for configuration editor

Validation function takes two argument: id for which it is called and array of fields' values (usually values for entire formset). The function must always return an array with an error (or error array) assigned to a form element (formset name or field path). Even if there are no errors, key must be set with an empty value.

Validation functions are assigned in $cfg_db['_validators'] (config.values.php).

Methods

__construct(ConfigFile $configFile)

No description

array
getValidators()

Returns validator list

bool|array
validate(array $validatorIds, array $values, bool $isPostSource)

Runs validation $validator_id on values $values and returns error list.

Details

__construct(ConfigFile $configFile)

No description

Parameters

ConfigFile $configFile

array getValidators()

Returns validator list

Return Value

array

bool|array validate(array $validatorIds, array $values, bool $isPostSource)

Runs validation $validator_id on values $values and returns error list.

Return values: o array, keys - field path or formset id, values - array of errors when $isPostSource is true values is an empty array to allow for error list cleanup in HTML document o false - when no validators match name(s) given by $validator_id

Parameters

array $validatorIds

ID of validator(s) to run

array $values

Values to validate

bool $isPostSource

tells whether $values are directly from POST request

Return Value

bool|array