Validator
class Validator (View source)
Validation class for various validation functions
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
Runs validation $validator_id on values $values and returns error list.
Test database connection
Validate server config
Validate pmadb config
Validates regular expression
Validates TrustedProxies field
Tests integer value
Validates port number
Validates positive number
Validates non-negative number
Validates value according to given regular expression Pattern and modifiers must be a valid for PCRE and JavaScript RegExp
Validates upper bound for numeric inputs
Details
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.
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
static bool|array
testDBConnection(string $host, string $port, string $socket, string $user, string $pass, string $errorKey = 'Server')
Test database connection
static array
validateServer(string $path, array $values)
Validate server config
static array
validatePMAStorage(string $path, array $values)
Validate pmadb config
static array
validateRegex(string $path, array $values)
Validates regular expression
static array
validateTrustedProxies(string $path, array $values)
Validates TrustedProxies field
static string
validateNumber(string $path, array $values, bool $allowNegative, bool $allowZero, int $maxValue, string $errorString)
Tests integer value
static array
validatePortNumber(string $path, array $values)
Validates port number
static array
validatePositiveNumber(string $path, array $values)
Validates positive number
static array
validateNonNegativeNumber(string $path, array $values)
Validates non-negative number
static array|string
validateByRegex(string $path, array $values, string $regex)
Validates value according to given regular expression Pattern and modifiers must be a valid for PCRE and JavaScript RegExp
static array
validateUpperBound(string $path, array $values, int $maxValue)
Validates upper bound for numeric inputs