@@ 26-42 (lines=17) @@ | ||
23 | } |
|
24 | ||
25 | $errors = []; |
|
26 | foreach ($value as $key => $itemValue) { |
|
27 | $schema = self::getSchema($parameter, $key); |
|
28 | ||
29 | // Additional items are allowed by default, |
|
30 | // so there might not be a schema for this. |
|
31 | if (is_null($schema)) { |
|
32 | continue; |
|
33 | } |
|
34 | ||
35 | $subValidator = $validator->makeSubSchemaValidator( |
|
36 | $itemValue, |
|
37 | $schema, |
|
38 | pointer_push($validator->getDataPath(), $key), |
|
39 | pointer_push($validator->getSchemaPath(), $key) |
|
40 | ); |
|
41 | $errors = array_merge($errors, $subValidator->errors()); |
|
42 | } |
|
43 | ||
44 | return $errors ?: null; |
|
45 | } |
@@ 27-39 (lines=13) @@ | ||
24 | ||
25 | // Iterate through the properties and create a new validator for that property's schema and data. |
|
26 | $errors = []; |
|
27 | foreach ($parameter as $property => $schema) { |
|
28 | if (is_object($value) && property_exists($value, $property)) { |
|
29 | $subValidator = $validator->makeSubSchemaValidator( |
|
30 | $value->$property, |
|
31 | $schema, |
|
32 | pointer_push($validator->getDataPath(), $property), |
|
33 | pointer_push($validator->getSchemaPath(), $property) |
|
34 | ); |
|
35 | if ($subValidator->fails()) { |
|
36 | $errors = array_merge($errors, $subValidator->errors()); |
|
37 | } |
|
38 | } |
|
39 | } |
|
40 | ||
41 | return $errors; |
|
42 | } |