Documentation

rex_validator
in package
Uses rex_factory_trait

Validator class.

Tags
author

gharlan

Table of Contents

Methods

add()  : $this
Adds a validation rule.
addRule()  : $this
Adds a validation rule.
custom()  : bool
Checks the value by using the given callable.
email()  : bool
Checks whether the value is an email address.
factory()  : static
Factory method.
getMessage()  : string|null
Returns the message.
getRules()  : array<int, rex_validation_rule>
isValid()  : bool
Checks whether the given value matches all added validators.
match()  : bool
Checks whether the value matches the given regex.
max()  : bool
Checks whether the value is equal or lower than the given max value.
maxLength()  : bool
Checks whether the value has the given max value.
min()  : bool
Checks whether the value is equal or greater than the given min value.
minLength()  : bool
Checks whether the value has the given min length.
notEmpty()  : bool
Checks whether the value is not empty.
notMatch()  : bool
Checks whether the value does not match the given regex.
type()  : bool
Checks whether the value is from the given type.
url()  : bool
Checks whether the value is an URL.
values()  : bool
Checks whether the value is one of the given valid values.
__construct()  : mixed

Methods

add()

Adds a validation rule.

public add(string $type[, string|null $message = null ][, mixed $option = null ]) : $this
Parameters
$type : string

Validator type (any static method name of this class)

$message : string|null = null

Message which is used if this validator type does not match

$option : mixed = null

Type specific option

Tags
throws
InvalidArgumentException
Return values
$this

custom()

Checks the value by using the given callable.

public custom(string $value, callable(string): bool $callback) : bool
Parameters
$value : string
$callback : callable(string): bool
Return values
bool

email()

Checks whether the value is an email address.

public email(string $value) : bool
Parameters
$value : string
Return values
bool

factory()

Factory method.

public static factory() : static
Return values
static

getMessage()

Returns the message.

public getMessage() : string|null
Return values
string|null

isValid()

Checks whether the given value matches all added validators.

public isValid(string $value) : bool
Parameters
$value : string
Return values
bool

match()

Checks whether the value matches the given regex.

public match(string $value, string $regex) : bool
Parameters
$value : string
$regex : string
Return values
bool

max()

Checks whether the value is equal or lower than the given max value.

public max(string $value, int $max) : bool
Parameters
$value : string
$max : int
Return values
bool

maxLength()

Checks whether the value has the given max value.

public maxLength(string $value, int $maxLength) : bool
Parameters
$value : string
$maxLength : int
Return values
bool

min()

Checks whether the value is equal or greater than the given min value.

public min(string $value, int $min) : bool
Parameters
$value : string
$min : int
Return values
bool

minLength()

Checks whether the value has the given min length.

public minLength(string $value, int $minLength) : bool
Parameters
$value : string
$minLength : int
Return values
bool

notEmpty()

Checks whether the value is not empty.

public notEmpty(string $value) : bool
Parameters
$value : string
Return values
bool

notMatch()

Checks whether the value does not match the given regex.

public notMatch(string $value, string $regex) : bool
Parameters
$value : string
$regex : string
Return values
bool

type()

Checks whether the value is from the given type.

public type(string $value, string $type) : bool
Parameters
$value : string
$type : string
Tags
throws
InvalidArgumentException
Return values
bool

url()

Checks whether the value is an URL.

public url(string $value) : bool
Parameters
$value : string
Return values
bool

values()

Checks whether the value is one of the given valid values.

public values(string $value, array<string|int, mixed> $validValues) : bool
Parameters
$value : string
$validValues : array<string|int, mixed>
Return values
bool

__construct()

protected __construct() : mixed

        
On this page

Search results