\CodeIgniter\ValidationRules

Validation Rules.

Summary

Methods
Properties
Constants
differs()
equals()
exact_length()
greater_than()
greater_than_equal_to()
in_list()
is_unique()
less_than()
less_than_equal_to()
matches()
max_length()
min_length()
not_equals()
required()
required_with()
required_without()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

differs()

differs(string  $str = null, string  $field, array  $data) : boolean

The value does not match another field in $data.

Parameters

string $str
string $field
array $data

Other field/value pairs

Returns

boolean

equals()

equals(string  $str = null, string  $val) : boolean

Equals the static value provided.

Parameters

string $str
string $val

Returns

boolean

exact_length()

exact_length(string  $str = null, string  $val, array  $data) : boolean

Returns true if $str is $val characters long.

$val = "5" (one) | "5,8,12" (multiple values)

Parameters

string $str
string $val
array $data

Returns

boolean

greater_than()

greater_than(string  $str = null, string  $min, array  $data) : boolean

Greater than

Parameters

string $str
string $min
array $data

Returns

boolean

greater_than_equal_to()

greater_than_equal_to(string  $str = null, string  $min, array  $data) : boolean

Equal to or Greater than

Parameters

string $str
string $min
array $data

Returns

boolean

in_list()

in_list(string  $value = null, string  $list, array  $data) : boolean

Value should be within an array of values

Parameters

string $value
string $list
array $data

Returns

boolean

is_unique()

is_unique(string  $str = null, string  $field, array  $data) : boolean

Checks the database to see if the given value is unique. Can ignore a single record by field/value to make it useful during record updates.

Example: is_unique[table.field,ignore_field,ignore_value] is_unique[users.email,id,5]

Parameters

string $str
string $field
array $data

Returns

boolean

less_than()

less_than(string  $str = null, string  $max) : boolean

Less than

Parameters

string $str
string $max

Returns

boolean

less_than_equal_to()

less_than_equal_to(string  $str = null, string  $max) : boolean

Equal to or Less than

Parameters

string $str
string $max

Returns

boolean

matches()

matches(string  $str = null, string  $field, array  $data) : boolean

Matches the value of another field in $data.

Parameters

string $str
string $field
array $data

Other field/value pairs

Returns

boolean

max_length()

max_length(string  $str = null, string  $val, array  $data) : boolean

Returns true if $str is $val or fewer characters in length.

Parameters

string $str
string $val
array $data

Returns

boolean

min_length()

min_length(string  $str = null, string  $val, array  $data) : boolean

Returns true if $str is at least $val length.

Parameters

string $str
string $val
array $data

Returns

boolean

not_equals()

not_equals(string  $str = null, string  $val) : boolean

Does not equal the static value provided.

Parameters

string $str
string $val

Returns

boolean

required()

required(mixed  $str = null) : boolean

Required

Parameters

mixed $str

Value

Returns

boolean —

True if valid, false if not

required_with()

required_with(  $str = null, string  $fields, array  $data) : boolean

The field is required when any of the other required fields are present in the data.

Example (field is required when the password field is present):

required_with[password]

Parameters

$str
string $fields

List of fields that we should check if present

array $data

Complete list of fields from the form

Returns

boolean

required_without()

required_without(  $str = null, string  $fields, array  $data) : boolean

The field is required when all of the other fields are present in the data but not required.

Example (field is required when the id or email field is missing):

required_without[id,email]

Parameters

$str
string $fields
array $data

Returns

boolean