class DataValidation (View source)

Constants

STRING

BOOL

BOOLEAN

INT

INTEGER

NUMBER

DOUBLE

FLOAT

JSON

SERIALIZED

ARRAYSTRICT

STRUCT

DATETIMEISO8601

BASE64

NULLVALUE

TIMESTAMP

Methods

static bool
validate(mixed $data, string $type, callable $filter = null)

Generic validator.

static bool
validateString(mixed $data, callable $filter = null)

String validator.

static bool
validateBoolean(mixed $data, callable $filter = null)

Bool validator.

static bool
validateInteger(mixed $data, callable $filter = null)

Int validator.

static bool
validateNumeric(mixed $data, callable $filter = null)

Numeric validator.

static bool
validateFloat(mixed $data, callable $filter = null)

Float validator.

static bool
validateJson(mixed $data, callable $filter = null)

Json validator.

static bool
validateSerialized(mixed $data, callable $filter = null)

Serialized values validator.

static bool
validateArray(mixed $data, callable $filter = null)

Array (strict) validator.

static bool
validateStruct(mixed $data, callable $filter = null)

Struct (strict) validator.

static bool
validateDatetimeIso8601(mixed $data, callable $filter = null)

Iso8601-datetime validator.

static bool
validateBase64(mixed $data, callable $filter = null)

Base64 validator.

static bool
validateNull(mixed $data, callable $filter = null)

Null value validator.

static bool
validateTimestamp(mixed $data, callable $filter = null)

Timestamp (epoch) validator.

Details

static bool validate(mixed $data, string $type, callable $filter = null)

Generic validator.

Parameters

mixed $data Data to validate
string $type Type (one of self::$supported_types)
callable $filter Custom filter

Return Value

bool

Exceptions

UnexpectedValueException

static bool validateString(mixed $data, callable $filter = null)

String validator.

Parameters

mixed $data Data to validate
callable $filter Custom filter

Return Value

bool

static bool validateBoolean(mixed $data, callable $filter = null)

Bool validator.

Parameters

mixed $data Data to validate
callable $filter Custom filter

Return Value

bool

static bool validateInteger(mixed $data, callable $filter = null)

Int validator.

Parameters

mixed $data Data to validate
callable $filter Custom filter

Return Value

bool

static bool validateNumeric(mixed $data, callable $filter = null)

Numeric validator.

Parameters

mixed $data Data to validate
callable $filter Custom filter

Return Value

bool

static bool validateFloat(mixed $data, callable $filter = null)

Float validator.

Parameters

mixed $data Data to validate
callable $filter Custom filter

Return Value

bool

static bool validateJson(mixed $data, callable $filter = null)

Json validator.

Parameters

mixed $data Data to validate
callable $filter Custom filter

Return Value

bool

static bool validateSerialized(mixed $data, callable $filter = null)

Serialized values validator.

Parameters

mixed $data Data to validate
callable $filter Custom filter

Return Value

bool

static bool validateArray(mixed $data, callable $filter = null)

Array (strict) validator.

Parameters

mixed $data Data to validate
callable $filter Custom filter

Return Value

bool

static bool validateStruct(mixed $data, callable $filter = null)

Struct (strict) validator.

Parameters

mixed $data Data to validate
callable $filter Custom filter

Return Value

bool

static bool validateDatetimeIso8601(mixed $data, callable $filter = null)

Iso8601-datetime validator.

Parameters

mixed $data Data to validate
callable $filter Custom filter

Return Value

bool

static bool validateBase64(mixed $data, callable $filter = null)

Base64 validator.

Parameters

mixed $data Data to validate
callable $filter Custom filter

Return Value

bool

static bool validateNull(mixed $data, callable $filter = null)

Null value validator.

Parameters

mixed $data Data to validate
callable $filter Custom filter

Return Value

bool

static bool validateTimestamp(mixed $data, callable $filter = null)

Timestamp (epoch) validator.

Parameters

mixed $data Data to validate
callable $filter Custom filter

Return Value

bool