class Validators extends Object

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
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 76
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 102
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 120
static bool is($value, $expected)

Finds whether a variable is of expected type.

Parameters

$value
$expected

Return Value

bool

at line 164
static bool isNumericInt($value)

Finds whether a value is an integer.

Parameters

$value

Return Value

bool

at line 174
static bool isNumeric($value)

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

Parameters

$value

Return Value

bool

at line 184
static bool isCallable($value)

Finds whether a value is a syntactically correct callback.

Parameters

$value

Return Value

bool

at line 195
static bool isUnicode($value)

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

Parameters

$value

Return Value

bool

at line 205
static bool isNone($value)

Finds whether a value is "falsy".

Parameters

$value

Return Value

bool

at line 216
static bool isList($value)

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

Parameters

$value

Return Value

bool

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

Is a value in specified range?

Parameters

$value
$range

Return Value

bool

at line 240
static bool isEmail($value)

Finds whether a string is a valid email address.

Parameters

$value

Return Value

bool

at line 258
static bool isUrl($value)

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

Parameters

$value

Return Value

bool

at line 279
static bool isUri($value)

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

Parameters

$value

Return Value

bool

at line 290
static bool isType($type)

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

Parameters

$type

Return Value

bool

at line 300
static bool isPhpIdentifier($value)

Checks whether the input is a valid PHP identifier.

Parameters

$value

Return Value

bool