@@ -109,20 +109,20 @@ protected function validateCommonProperties($value, $schema = null, $path = null
109
109
110
110
// Verify required values
111
111
if (is_object ($ value )) {
112
- if ($ value instanceof Undefined) {
113
- // Draft 3 - Required attribute - e.g. "foo": {"type": "string", "required": true}
114
- if (isset ($ schema ->required ) && $ schema ->required ) {
115
- $ this ->addError ($ path , "is missing and it is required " );
112
+ if (isset ($ schema ->required ) && is_array ($ schema ->required ) ) {
113
+ // Draft 4 - Required is an array of strings - e.g. "required": ["foo", ...]
114
+ foreach ($ schema ->required as $ required ) {
115
+ if (!property_exists ($ value , $ required )) {
116
+ $ this ->addError ($ path , "the property " . $ required . " is required " );
117
+ }
116
118
}
117
119
} else if (isset ($ schema ->required )) {
118
- if ( is_array ($ schema ->required )) {
119
- // Draft 4 - Required is an array of strings - e.g. "required": ["foo", ...]
120
- foreach ($ schema ->required as $ required ) {
121
- if (!property_exists ($ value , $ required )) {
122
- $ this ->addError ($ path , "the property " . $ required . " is required " );
123
- }
124
- }
120
+ // Draft 3 - Required attribute - e.g. "foo": {"type": "string", "required": true}
121
+ if ( $ schema ->required && $ value instanceof Undefined) {
122
+ $ this ->addError ($ path , "is missing and it is required " );
125
123
}
124
+ } else if ($ value instanceof Undefined) {
125
+ // don't check type of Undefined value
126
126
} else {
127
127
$ this ->checkType ($ value , $ schema , $ path );
128
128
}
0 commit comments