Open jonathansilva opened 3 years ago
I'm trying to use the same features as Joi... accept object array and objects with key : value
[{"key": "value"}, ...] {"key": "value", ...}
private function sanitize($data) { $schema = V::obj()->keys([ 'myArray' => V::arr()->keys([ 'test' => V::string() ]) ]); V::assert($data, $schema); } ... class ArrayKeys extends AbstractAssertion { public function process(InputValue $input) { echo '<pre>'; var_dump($input->getValue()); echo '</pre>'; foreach ($this->getOption('keys') as $key => $schema) { if (!array_key_exists($key, $input->getValue())) { throw new ValidationException(sprintf('key "%s" is missing', $key)); } $this->validateAndReplaceKey($input, $key, $schema); } } }
I'm trying to use the same features as Joi... accept object array and objects with key : value
[{"key": "value"}, ...] {"key": "value", ...}
Postman