class DataValidator (View source)

Methods

static void
checkTypes(array $data, array $types, bool $complete = true)

No description

Details

static void checkTypes(array $data, array $types, bool $complete = true)

Parameters

array $data Data array to valdiate
array $types Expected types in the data array. Keys match with the keys from the data array, the values of this array are the expected types as strings. In case of objects this is the fully qualified classname, for other types this can be any of the return values of PHP's gettype() function. When a type is prefixed with ? it is optional and not required to be in the data array.
bool $complete Indicates whether the $types parameter completely covers the data. If any additional fields are found in the $data array that are not in the $types array an exception is thrown. When false additional fields are ignored.

Return Value

void Returns nothing but only returns when the data is valid. Otherwise an exception is thrown.

Exceptions

DataValidationException