class Validators

Validation utilities.

Traits

Static class.

Properties

static protected $validators
static protected $counters

Methods

static void
assert($value, string $expected, string $label = 'variable')

Throws exception if a variable is of unexpected type (separated by pipe).

static void
assertField(array $arr, $field, string $expected = null, string $label = "item '%' in array")

Throws exception if an array field is missing or of unexpected type (separated by pipe).

static bool
is($value, string $expected)

Finds whether a variable is of expected type (separated by pipe).

static bool
everyIs(iterable $values, string $expected)

Finds whether all values are of expected type (separated by pipe).

static bool
isNumber($value)

Finds whether a value is an integer or a float.

static bool
isNumericInt($value)

Finds whether a value is an integer.

static bool
isNumeric($value)

Finds whether a string is a floating point number in decimal base.

static bool
isCallable($value)

Finds whether a value is a syntactically correct callback.

static bool
isUnicode($value)

Finds whether a value is an UTF-8 encoded string.

static bool
isNone($value)

Finds whether a value is "falsy".

static bool
isMixed()

No description

static bool
isList($value)

Finds whether a variable is a zero-based integer indexed array.

static bool
isInRange($value, array $range)

Is a value in specified min and max value pair?

static bool
isEmail(string $value)

Finds whether a string is a valid email address.

static bool
isUrl(string $value)

Finds whether a string is a valid http(s) URL.

static bool
isUri(string $value)

Finds whether a string is a valid URI according to RFC 1738.

static bool
isType(string $type)

Checks whether the input is a class, interface or trait.

static bool
isPhpIdentifier(string $value)

Checks whether the input is a valid PHP identifier.

Details

at line 89
static void assert($value, string $expected, string $label = 'variable')

Throws exception if a variable is of unexpected type (separated by pipe).

Parameters

$value
string $expected
string $label

Return Value

void

at line 108
static void assertField(array $arr, $field, string $expected = null, string $label = "item '%' in array")

Throws exception if an array field is missing or of unexpected type (separated by pipe).

Parameters

array $arr
$field
string $expected
string $label

Return Value

void

at line 122
static bool is($value, string $expected)

Finds whether a variable is of expected type (separated by pipe).

Parameters

$value
string $expected

Return Value

bool

at line 177
static bool everyIs(iterable $values, string $expected)

Finds whether all values are of expected type (separated by pipe).

Parameters

iterable $values
string $expected

Return Value

bool

at line 191
static bool isNumber($value)

Finds whether a value is an integer or a float.

Parameters

$value

Return Value

bool

at line 200
static bool isNumericInt($value)

Finds whether a value is an integer.

Parameters

$value

Return Value

bool

at line 209
static bool isNumeric($value)

Finds whether a string is a floating point number in decimal base.

Parameters

$value

Return Value

bool

at line 218
static bool isCallable($value)

Finds whether a value is a syntactically correct callback.

Parameters

$value

Return Value

bool

at line 227
static bool isUnicode($value)

Finds whether a value is an UTF-8 encoded string.

Parameters

$value

Return Value

bool

at line 236
static bool isNone($value)

Finds whether a value is "falsy".

Parameters

$value

Return Value

bool

at line 243
static bool isMixed()

Return Value

bool

at line 252
static bool isList($value)

Finds whether a variable is a zero-based integer indexed array.

Parameters

$value

Return Value

bool

at line 261
static bool isInRange($value, array $range)

Is a value in specified min and max value pair?

Parameters

$value
array $range

Return Value

bool

at line 285
static bool isEmail(string $value)

Finds whether a string is a valid email address.

Parameters

string $value

Return Value

bool

at line 301
static bool isUrl(string $value)

Finds whether a string is a valid http(s) URL.

Parameters

string $value

Return Value

bool

at line 320
static bool isUri(string $value)

Finds whether a string is a valid URI according to RFC 1738.

Parameters

string $value

Return Value

bool

at line 329
static bool isType(string $type)

Checks whether the input is a class, interface or trait.

Parameters

string $type

Return Value

bool

at line 338
static bool isPhpIdentifier(string $value)

Checks whether the input is a valid PHP identifier.

Parameters

string $value

Return Value

bool