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

static array
getValidators(ConfigFile $cf)

Returns validator list

static bool|array
validate(ConfigFile $cf, string|array $validatorId, array $values, bool $isPostSource)

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

Details

static array getValidators(ConfigFile $cf)

Returns validator list

Parameters

ConfigFile $cf

Config file instance

Return Value

array

static bool|array validate(ConfigFile $cf, string|array $validatorId, 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

ConfigFile $cf

Config file instance

string|array $validatorId

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