Add validateArray method
[MAILPOET-4700]
This commit is contained in:
@@ -25,7 +25,18 @@ class Validator {
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function validate(Schema $schema, $value, string $paramName = 'value') {
|
public function validate(Schema $schema, $value, string $paramName = 'value') {
|
||||||
$result = $this->validateAndSanitizeValueFromSchema($value, $schema->toArray(), $paramName);
|
return $this->validateArray($schema->toArray(), $value, $paramName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Strict validation & sanitization implementation.
|
||||||
|
* It only coerces int to float (e.g. 5 to 5.0).
|
||||||
|
*
|
||||||
|
* @param mixed $value
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function validateArray(array $schema, $value, string $paramName = 'value') {
|
||||||
|
$result = $this->validateAndSanitizeValueFromSchema($value, $schema, $paramName);
|
||||||
if ($result instanceof WP_Error) {
|
if ($result instanceof WP_Error) {
|
||||||
throw ValidationException::createFromWpError($result);
|
throw ValidationException::createFromWpError($result);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user