@@ -25,17 +25,10 @@ class UndefinedConstraint extends Constraint
2525 */
2626 public function check ($ value , $ schema = null , $ path = null , $ i = null )
2727 {
28- if (is_null ($ schema )) {
28+ if (is_null ($ schema ) || ! is_object ( $ schema ) ) {
2929 return ;
3030 }
3131
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-
3932 $ i = is_null ($ i ) ? "" : $ i ;
4033 $ path = $ this ->incrementPath ($ path , $ i );
4134
@@ -65,10 +58,10 @@ public function validateTypes($value, $schema = null, $path = null, $i = null)
6558 }
6659
6760 // check object
68- if (is_object ($ value ) && ( isset ( $ schema -> properties ) || isset ( $ schema -> patternProperties ) || isset ( $ schema -> additionalProperties )) ) {
61+ if (is_object ($ value )) {
6962 $ this ->checkObject (
7063 $ value ,
71- isset ($ schema ->properties ) ? $ schema ->properties : null ,
64+ isset ($ schema ->properties ) ? $ schema ->properties : $ schema ,
7265 $ path ,
7366 isset ($ schema ->additionalProperties ) ? $ schema ->additionalProperties : null ,
7467 isset ($ schema ->patternProperties ) ? $ schema ->patternProperties : null
@@ -165,20 +158,6 @@ protected function validateCommonProperties($value, $schema = null, $path = null
165158 }
166159 }
167160
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-
182161 // Verify that dependencies are met
183162 if (is_object ($ value ) && isset ($ schema ->dependencies )) {
184163 $ this ->validateDependencies ($ value , $ schema ->dependencies , $ path );
0 commit comments