class Validators

Validation utilities.

Properties

static protected $validators
static protected $counters

Methods

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

Throws exception if a variable is of unexpected type.

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

Throws exception if an array field is missing or of unexpected type.

static bool
is($value, $expected)

Finds whether a variable is of expected type.

static bool
everyIs($values, $expected)

Finds whether all values are of expected type.

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
isList($value)

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

static bool
isInRange($value, $range)

Is a value in specified range?

static bool
isEmail($value)

Finds whether a string is a valid email address.

static bool
isUrl($value)

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

static bool
isUri($value)

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

static bool
isType($type)

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

static bool
isPhpIdentifier($value)

Checks whether the input is a valid PHP identifier.

Details

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

Throws exception if a variable is of unexpected type.

Parameters

$value
$expected
$label

Return Value

void

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

Throws exception if an array field is missing or of unexpected type.

Parameters

$arr
$field
$expected
$label

Return Value

void

at line 121
static bool is($value, $expected)

Finds whether a variable is of expected type.

Parameters

$value
$expected

Return Value

bool

at line 170
static bool everyIs($values, $expected)

Finds whether all values are of expected type.

Parameters

$values
$expected

Return Value

bool

at line 188
static bool isNumber($value)

Finds whether a value is an integer or a float.

Parameters

$value

Return Value

bool

at line 198
static bool isNumericInt($value)

Finds whether a value is an integer.

Parameters

$value

Return Value

bool

at line 208
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 229
static bool isUnicode($value)

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

Parameters

$value

Return Value

bool

at line 239
static bool isNone($value)

Finds whether a value is "falsy".

Parameters

$value

Return Value

bool

at line 250
static bool isList($value)

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

Parameters

$value

Return Value

bool

at line 262
static bool isInRange($value, $range)

Is a value in specified range?

Parameters

$value
$range

Return Value

bool

at line 288
static bool isEmail($value)

Finds whether a string is a valid email address.

Parameters

$value

Return Value

bool

at line 306
static bool isUrl($value)

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

Parameters

$value

Return Value

bool

at line 327
static bool isUri($value)

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

Parameters

$value

Return Value

bool

at line 338
static bool isType($type)

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

Parameters

$type

Return Value

bool

at line 348
static bool isPhpIdentifier($value)

Checks whether the input is a valid PHP identifier.

Parameters

$value

Return Value

bool

Traits

Static class.