class Validator (View source)

Traits

Properties

protected bool $fails

The Fails flag

protected ?string $last_message

The last name

protected array $errors

The errors list

protected array $inputs

The validation DATA

protected array $messages

The user messages

protected array $rules

Define the valid rule list

Methods

void
compileExists(string $key, string $masque)

Compile Exists Rule

void
compileNotExists(string $key, string $masque)

Compile Not Exists Rule

void
compileUnique(string $key, string $masque)

Compile Unique Rule

void
compileDate(string $key, string $masque)

Compile Date Rule

void
compileDateTime(string $key, string $masque)

Compile Date Time Rule

void
compileEmail(string $key, string $masque)

Compile Email Rule

void
compileNumber(string $key, string $masque)

Compile Number Rule

void
compileInt(string $key, string $masque)

Compile Int Rule

void
compileFloat(string $key, string $masque)

Compile Float Rule

void
compileRequired(string $key, string $masque)

Compile Required Rule

void
compileRequiredIf(string $key, string $masque)

Compile Required Rule

void
compileEmpty(string $key, string $masque)

Compile Empty Rule

void
compileAlphaNum(string $key, string $masque)

Compile Alphanum Rule

void
compileIn(string $key, string $masque)

Compile In Rule

void
compileSize(string $key, string $masque)

Compile Size Rule

void
compileLower(string $key, string $masque)

Compile Lower Rule

void
compileUpper(string $key, string $masque)

Compile Upper Rule

void
compileAlpha(string $key, string $masque)

Compile Alpha Rule

void
compileMin(string $key, string $masque)

Compile Min Mask

void
compileMax(string $key, string $masque)

Compile Max Rule

void
compileSame(string $key, string $masque)

Compile Some Rule

void
compileRegex(string $key, string|int|float $masque)

Compile Regex Rule

bool
compileNullable(string $key, string $masque)

Compile Nullable Rule

void
compileUrl(string $key, string $masque)

Compile Url Rule

from  UrlRule
void
compileIp(string $key, string $masque)

Compile Ip Rule

from  IpRule
void
compileBoolean(string $key, string $masque)

Compile Boolean Rule

void
compileJson(string $key, string $masque)

Compile Json Rule

from  JsonRule
void
compileUuid(string $key, string $masque)

Compile Uuid Rule

from  UuidRule
void
compileConfirmed(string $key, string $masque)

Compile Confirmed Rule

void
compileDifferent(string $key, string $masque)

Compile Different Rule

void
compileBetween(string $key, string $masque)

Compile Between Rule

void
__construct()

Validator constructor

static Validate
make(array $inputs, array $rules, array $messages = [])

Any possible markers.

setCustomMessages(array $messages)

Set the user custom message

validate(array $inputs, array $rules)

Make validation

Details

protected void compileExists(string $key, string $masque)

Compile Exists Rule

[exists:table,column] Check that the contents of a table field exist

Parameters

string $key
string $masque

Return Value

void

Exceptions

QueryBuilderException

protected void compileNotExists(string $key, string $masque)

Compile Not Exists Rule

[!exists:table,column] Checks that the contents of the field of a table do not exist

Parameters

string $key
string $masque

Return Value

void

Exceptions

QueryBuilderException

protected void compileUnique(string $key, string $masque)

Compile Unique Rule

[unique:table,column] Check that the contents of the field of a table is a single value

Parameters

string $key
string $masque

Return Value

void

Exceptions

QueryBuilderException

protected void compileDate(string $key, string $masque)

Compile Date Rule

[date] Check that the field's content is a valid date

Parameters

string $key
string $masque

Return Value

void

protected void compileDateTime(string $key, string $masque)

Compile Date Time Rule

[datetime] Check that the contents of the field is a valid date time

Parameters

string $key
string $masque

Return Value

void

protected void compileEmail(string $key, string $masque)

Compile Email Rule

[email] Check that the content of the field is an email

Parameters

string $key
string $masque

Return Value

void

protected void compileNumber(string $key, string $masque)

Compile Number Rule

[number] Check that the contents of the field is a number

Parameters

string $key
string $masque

Return Value

void

protected void compileInt(string $key, string $masque)

Compile Int Rule

[int] Check that the contents of the field is an integer number

Parameters

string $key
string $masque

Return Value

void

protected void compileFloat(string $key, string $masque)

Compile Float Rule

[float] Check that the field content is a float number

Parameters

string $key
string $masque

Return Value

void

protected void compileRequired(string $key, string $masque)

Compile Required Rule

Parameters

string $key
string $masque

Return Value

void

protected void compileRequiredIf(string $key, string $masque)

Compile Required Rule

Parameters

string $key
string $masque

Return Value

void

Exceptions

ValidationException

protected void compileEmpty(string $key, string $masque)

Compile Empty Rule

Parameters

string $key
string $masque

Return Value

void

protected void compileAlphaNum(string $key, string $masque)

Compile Alphanum Rule

[alphanum] Check that the field content is an alphanumeric string

Parameters

string $key
string $masque

Return Value

void

protected void compileIn(string $key, string $masque)

Compile In Rule

[in:(value, ...)] Check that the contents of the field are equal to the defined value

Parameters

string $key
string $masque

Return Value

void

protected void compileSize(string $key, string $masque)

Compile Size Rule

[size:value] Check that the contents of the field is a number of character equal to the defined value

Parameters

string $key
string $masque

Return Value

void

protected void compileLower(string $key, string $masque)

Compile Lower Rule

[lower] Check that the content of the field is a string in miniscule

Parameters

string $key
string $masque

Return Value

void

protected void compileUpper(string $key, string $masque)

Compile Upper Rule

[upper] Check that the contents of the field is a string in uppercase

Parameters

string $key
string $masque

Return Value

void

protected void compileAlpha(string $key, string $masque)

Compile Alpha Rule

[alpha] Check that the field content is an alpha

Parameters

string $key
string $masque

Return Value

void

protected void compileMin(string $key, string $masque)

Compile Min Mask

[min:value] Check that the content of the field is a number of minimal character following the defined value

Parameters

string $key
string $masque

Return Value

void

protected void compileMax(string $key, string $masque)

Compile Max Rule

[max:value] Check that the content of the field is a number of maximum character following the defined value

Parameters

string $key
string $masque

Return Value

void

protected void compileSame(string $key, string $masque)

Compile Some Rule

[same:value] Check that the field contents are equal to the mask value

Parameters

string $key
string $masque

Return Value

void

protected void compileRegex(string $key, string|int|float $masque)

Compile Regex Rule

Check that the contents of the field with a regular expression

Parameters

string $key
string|int|float $masque

Return Value

void

protected bool compileNullable(string $key, string $masque)

Compile Nullable Rule

[nullable] Check that the content of the field is nullable

Parameters

string $key
string $masque

Return Value

bool

protected void compileUrl(string $key, string $masque)

Compile Url Rule

[url] Check that the contents of the field is a well-formed URL.

Parameters

string $key
string $masque

Return Value

void

protected void compileIp(string $key, string $masque)

Compile Ip Rule

[ip], [ip:v4], [ip:v6] — Check that the contents of the field is a valid IPv4/IPv6 address. With no suffix either version is accepted.

Parameters

string $key
string $masque

Return Value

void

protected void compileBoolean(string $key, string $masque)

Compile Boolean Rule

[boolean] / [bool] — Accepts true, false, 0, 1, "0", "1", "true", "false". Matches the typical form-input meaning rather than PHP's strict bool type.

Parameters

string $key
string $masque

Return Value

void

protected void compileJson(string $key, string $masque)

Compile Json Rule

[json] Check that the contents of the field is a syntactically valid JSON string.

Parameters

string $key
string $masque

Return Value

void

protected void compileUuid(string $key, string $masque)

Compile Uuid Rule

[uuid] Check that the contents of the field is a canonical RFC 4122 UUID (versions 1–5).

Parameters

string $key
string $masque

Return Value

void

protected void compileConfirmed(string $key, string $masque)

Compile Confirmed Rule

[confirmed] Check that the field matches a sibling field named <key>_confirmation. Common pattern for password / email confirmation.

Parameters

string $key
string $masque

Return Value

void

protected void compileDifferent(string $key, string $masque)

Compile Different Rule

[different:other_field] Check that the field's value is different from another field's value. Strict comparison; missing fields are treated as null (so a present field is automatically "different" from a missing one).

Parameters

string $key
string $masque

Return Value

void

protected void compileBetween(string $key, string $masque)

Compile Between Rule

[between:min,max] Check that the value is between min and max (inclusive). For numeric values the numeric value is checked; for strings the character length is checked — mirroring the convention used by min and max.

Parameters

string $key
string $masque

Return Value

void

void __construct()

Validator constructor

Return Value

void

static Validate make(array $inputs, array $rules, array $messages = [])

Any possible markers.

Parameters

array $inputs
array $rules
array $messages

Return Value

Validate

setCustomMessages(array $messages)

Set the user custom message

Parameters

array $messages

Validate validate(array $inputs, array $rules)

Make validation

Parameters

array $inputs
array $rules

Return Value

Validate