Documentation

Rules
in package

Validation Rules.

Table of Contents

differs()  : bool
The value does not match another field in $data.
equals()  : bool
Equals the static value provided.
exact_length()  : bool
Returns true if $str is $val characters long.
greater_than()  : bool
Greater than
greater_than_equal_to()  : bool
Equal to or Greater than
in_list()  : bool
Value should be within an array of values
is_not_unique()  : bool
Checks the database to see if the given value exist.
is_unique()  : bool
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.
less_than()  : bool
Less than
less_than_equal_to()  : bool
Equal to or Less than
matches()  : bool
Matches the value of another field in $data.
max_length()  : bool
Returns true if $str is $val or fewer characters in length.
min_length()  : bool
Returns true if $str is at least $val length.
not_equals()  : bool
Does not equal the static value provided.
not_in_list()  : bool
Value should not be within an array of values.
required()  : bool
Required
required_with()  : bool
The field is required when any of the other required fields are present in the data.
required_without()  : bool
The field is required when all of the other fields are present in the data but not required.

Methods

differs()

The value does not match another field in $data.

public differs([string $str = null ], string $field, array<string|int, mixed> $data) : bool
Parameters
$str : string = null
$field : string
$data : array<string|int, mixed>

Other field/value pairs

Return values
bool

equals()

Equals the static value provided.

public equals([string $str = null ], string $val) : bool
Parameters
$str : string = null
$val : string
Return values
bool

exact_length()

Returns true if $str is $val characters long.

public exact_length([string $str = null ], string $val) : bool

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

Parameters
$str : string = null
$val : string
Return values
bool

greater_than()

Greater than

public greater_than([string $str = null ], string $min) : bool
Parameters
$str : string = null
$min : string
Return values
bool

greater_than_equal_to()

Equal to or Greater than

public greater_than_equal_to([string $str = null ], string $min) : bool
Parameters
$str : string = null
$min : string
Return values
bool

in_list()

Value should be within an array of values

public in_list([string $value = null ], string $list) : bool
Parameters
$value : string = null
$list : string
Return values
bool

is_not_unique()

Checks the database to see if the given value exist.

public is_not_unique([string $str = null ], string $field, array<string|int, mixed> $data) : bool

Can ignore records by field/value to filter (currently accept only one filter).

Example: is_not_unique[table.field,where_field,where_value] is_not_unique[menu.id,active,1]

Parameters
$str : string = null
$field : string
$data : array<string|int, mixed>
Return values
bool

is_unique()

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.

public is_unique([string $str = null ], string $field, array<string|int, mixed> $data) : bool

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

Parameters
$str : string = null
$field : string
$data : array<string|int, mixed>
Return values
bool

less_than()

Less than

public less_than([string $str = null ], string $max) : bool
Parameters
$str : string = null
$max : string
Return values
bool

less_than_equal_to()

Equal to or Less than

public less_than_equal_to([string $str = null ], string $max) : bool
Parameters
$str : string = null
$max : string
Return values
bool

matches()

Matches the value of another field in $data.

public matches([string $str = null ], string $field, array<string|int, mixed> $data) : bool
Parameters
$str : string = null
$field : string
$data : array<string|int, mixed>

Other field/value pairs

Return values
bool

max_length()

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

public max_length([string $str = null ], string $val) : bool
Parameters
$str : string = null
$val : string
Return values
bool

min_length()

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

public min_length([string $str = null ], string $val) : bool
Parameters
$str : string = null
$val : string
Return values
bool

not_equals()

Does not equal the static value provided.

public not_equals([string $str = null ], string $val) : bool
Parameters
$str : string = null
$val : string
Return values
bool

not_in_list()

Value should not be within an array of values.

public not_in_list([string $value = null ], string $list) : bool
Parameters
$value : string = null
$list : string
Return values
bool

required()

Required

public required([mixed $str = null ]) : bool
Parameters
$str : mixed = null

Value

Return values
bool

True if valid, false if not

required_with()

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

public required_with([string|null $str = null ][, string|null $fields = null ][, array<string|int, mixed> $data = [] ]) : bool

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

required_with[password]

Parameters
$str : string|null = null
$fields : string|null = null

List of fields that we should check if present

$data : array<string|int, mixed> = []

Complete list of fields from the form

Return values
bool

required_without()

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

public required_without([string|null $str = null ][, string|null $fields = null ][, array<string|int, mixed> $data = [] ]) : bool

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

required_without[id,email]

Parameters
$str : string|null = null
$fields : string|null = null
$data : array<string|int, mixed> = []
Return values
bool

Search results