\CodeIgniter\ValidationValidationInterface

Expected behavior of a validator

Summary

Methods
Constants
run()
check()
withRequest()
setRules()
hasRule()
getError()
getErrors()
setError()
reset()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

run()

run(array  $data = null, string  $group = null) : boolean

Runs the validation process, returning true/false determining whether or not validation was successful.

Parameters

array $data

The array of data to validate.

string $group

The pre-defined group of rules to apply.

Returns

boolean

check()

check(mixed  $value, string  $rule, array<mixed,string>  $errors = array()) : boolean

Check; runs the validation process, returning true or false determining whether or not validation was successful.

Parameters

mixed $value

Value to validation.

string $rule

Rule.

array<mixed,string> $errors

Errors.

Returns

boolean —

True if valid, else false.

setRules()

setRules(array  $rules, array  $messages = array()) : \CodeIgniter\Validation\ValidationInterface

Stores the rules that should be used to validate the items.

Parameters

array $rules
array $messages

Returns

\CodeIgniter\Validation\ValidationInterface

hasRule()

hasRule(string  $field) : boolean

Checks to see if the rule for key $field has been set or not.

Parameters

string $field

Returns

boolean

getError()

getError(string  $field) : string

Returns the error for a specified $field (or empty string if not set).

Parameters

string $field

Returns

string

getErrors()

getErrors() : array

Returns the array of errors that were encountered during a run() call. The array should be in the following format:

[ 'field1' => 'error message', 'field2' => 'error message', ]

Returns

array

setError()

setError(string  $alias, string  $error) : \CodeIgniter\Validation\ValidationInterface

Sets the error for a specific field. Used by custom validation methods.

Parameters

string $alias
string $error

Returns

\CodeIgniter\Validation\ValidationInterface

reset()

reset() : \CodeIgniter\Validation\ValidationInterface

Resets the class to a blank slate. Should be called whenever you need to process more than one array.

Returns

\CodeIgniter\Validation\ValidationInterface