composer require peak/array-validation
General validation (stateless)
$validator = new Validator();
if ($validator->expectExactlyKeys($array, ['key1', 'key2', 'key3']) === true) {
// ...
}Advanced validation with fluent interface.
$validation = new StrictValidation($array);
// will throw an exception if any of tests below fail
$validation
->expectOnlyKeys(['id', 'title', 'description', 'isPrivate', 'tags'])
->expectAtLeastKeys(['id', 'title', 'description'])
->expectKeyToBeInteger('id')
->expectKeysToBeString(['title', 'description'])
->expectKeyToBeBoolean('isPrivate')
->expectKeyToBeArray('tags');
// if we reach this point, it means the array is
// valid according to the validation rules above.