@@ -25,17 +25,10 @@ class UndefinedConstraint extends Constraint
25
25
*/
26
26
public function check ($ value , $ schema = null , $ path = null , $ i = null )
27
27
{
28
- if (is_null ($ schema )) {
28
+ if (is_null ($ schema ) || ! is_object ( $ schema ) ) {
29
29
return ;
30
30
}
31
31
32
- if (!is_object ($ schema )) {
33
- throw new InvalidArgumentException (
34
- 'Given schema must be an object in ' . $ path
35
- . ' but is a ' . gettype ($ schema )
36
- );
37
- }
38
-
39
32
$ i = is_null ($ i ) ? "" : $ i ;
40
33
$ path = $ this ->incrementPath ($ path , $ i );
41
34
@@ -65,10 +58,10 @@ public function validateTypes($value, $schema = null, $path = null, $i = null)
65
58
}
66
59
67
60
// check object
68
- if (is_object ($ value ) && ( isset ( $ schema -> properties ) || isset ( $ schema -> patternProperties ) || isset ( $ schema -> additionalProperties )) ) {
61
+ if (is_object ($ value )) {
69
62
$ this ->checkObject (
70
63
$ value ,
71
- isset ($ schema ->properties ) ? $ schema ->properties : null ,
64
+ isset ($ schema ->properties ) ? $ schema ->properties : $ schema ,
72
65
$ path ,
73
66
isset ($ schema ->additionalProperties ) ? $ schema ->additionalProperties : null ,
74
67
isset ($ schema ->patternProperties ) ? $ schema ->patternProperties : null
@@ -165,20 +158,6 @@ protected function validateCommonProperties($value, $schema = null, $path = null
165
158
}
166
159
}
167
160
168
- // Verify minimum and maximum number of properties
169
- if (is_object ($ value )) {
170
- if (isset ($ schema ->minProperties )) {
171
- if (count (get_object_vars ($ value )) < $ schema ->minProperties ) {
172
- $ this ->addError ($ path , "Must contain a minimum of " . $ schema ->minProperties . " properties " , 'minProperties ' , array ('minProperties ' => $ schema ->minProperties ,));
173
- }
174
- }
175
- if (isset ($ schema ->maxProperties )) {
176
- if (count (get_object_vars ($ value )) > $ schema ->maxProperties ) {
177
- $ this ->addError ($ path , "Must contain no more than " . $ schema ->maxProperties . " properties " , 'maxProperties ' , array ('maxProperties ' => $ schema ->maxProperties ,));
178
- }
179
- }
180
- }
181
-
182
161
// Verify that dependencies are met
183
162
if (is_object ($ value ) && isset ($ schema ->dependencies )) {
184
163
$ this ->validateDependencies ($ value , $ schema ->dependencies , $ path );
0 commit comments