@@ -167,6 +167,10 @@ public function process($data, Context $options, $path = '#', $result = null)
167167 $ result = $ data ;
168168 }
169169
170+ if ($ options ->skipValidation ) {
171+ goto skipValidation;
172+ }
173+
170174 if ($ this ->type !== null ) {
171175 if (!Type::isValid ($ this ->type , $ data )) {
172176 $ this ->fail (new TypeException (ucfirst (
@@ -311,9 +315,10 @@ public function process($data, Context $options, $path = '#', $result = null)
311315 }
312316 }
313317
318+ skipValidation:
314319
315320 if ($ data instanceof \stdClass) {
316- if ($ this ->required !== null ) {
321+ if (! $ options -> skipValidation && $ this ->required !== null ) {
317322 foreach ($ this ->required as $ item ) {
318323 if (!property_exists ($ data , $ item )) {
319324 $ this ->fail (new ObjectException ('Required property missing: ' . $ item , ObjectException::REQUIRED ), $ path );
@@ -416,20 +421,23 @@ public function process($data, Context $options, $path = '#', $result = null)
416421 $ array = (array )$ data ;
417422 }
418423
419- if ($ this ->minProperties !== null && count ($ array ) < $ this ->minProperties ) {
420- $ this ->fail (new ObjectException ("Not enough properties " , ObjectException::TOO_FEW ), $ path );
421- }
422- if ($ this ->maxProperties !== null && count ($ array ) > $ this ->maxProperties ) {
423- $ this ->fail (new ObjectException ("Too many properties " , ObjectException::TOO_MANY ), $ path );
424+ if (!$ options ->skipValidation ) {
425+ if ($ this ->minProperties !== null && count ($ array ) < $ this ->minProperties ) {
426+ $ this ->fail (new ObjectException ("Not enough properties " , ObjectException::TOO_FEW ), $ path );
427+ }
428+ if ($ this ->maxProperties !== null && count ($ array ) > $ this ->maxProperties ) {
429+ $ this ->fail (new ObjectException ("Too many properties " , ObjectException::TOO_MANY ), $ path );
430+ }
424431 }
432+
425433 foreach ($ array as $ key => $ value ) {
426434 if ($ key === '' && PHP_VERSION_ID < 71000 ) {
427435 $ this ->fail (new InvalidValue ('Empty property name ' ), $ path );
428436 }
429437
430438 $ found = false ;
431439
432- if (!empty ($ this ->dependencies )) {
440+ if (!$ options -> skipValidation && ! empty ($ this ->dependencies )) {
433441 $ deps = $ this ->dependencies ;
434442 if (isset ($ deps ->$ key )) {
435443 $ dependencies = $ deps ->$ key ;
@@ -477,11 +485,14 @@ public function process($data, Context $options, $path = '#', $result = null)
477485 }
478486 }
479487 if (!$ found && $ this ->additionalProperties !== null ) {
480- if ($ this ->additionalProperties === false ) {
488+ if (! $ options -> skipValidation && $ this ->additionalProperties === false ) {
481489 $ this ->fail (new ObjectException ('Additional properties not allowed ' ), $ path . ': ' . $ key );
482490 }
483491
484- $ value = $ this ->additionalProperties ->process ($ value , $ options , $ path . '->additionalProperties: ' . $ key );
492+ if ($ this ->additionalProperties !== false ) {
493+ $ value = $ this ->additionalProperties ->process ($ value , $ options , $ path . '->additionalProperties: ' . $ key );
494+ }
495+
485496 if ($ import && !$ this ->useObjectAsArray ) {
486497 $ result ->addAdditionalPropertyName ($ key );
487498 }
@@ -511,12 +522,14 @@ public function process($data, Context $options, $path = '#', $result = null)
511522
512523 if (is_array ($ data )) {
513524
514- if ($ this ->minItems !== null && count ($ data ) < $ this ->minItems ) {
515- $ this ->fail (new ArrayException ("Not enough items in array " ), $ path );
516- }
525+ if (!$ options ->skipValidation ) {
526+ if ($ this ->minItems !== null && count ($ data ) < $ this ->minItems ) {
527+ $ this ->fail (new ArrayException ("Not enough items in array " ), $ path );
528+ }
517529
518- if ($ this ->maxItems !== null && count ($ data ) > $ this ->maxItems ) {
519- $ this ->fail (new ArrayException ("Too many items in array " ), $ path );
530+ if ($ this ->maxItems !== null && count ($ data ) > $ this ->maxItems ) {
531+ $ this ->fail (new ArrayException ("Too many items in array " ), $ path );
532+ }
520533 }
521534
522535 $ pathItems = 'items ' ;
@@ -542,15 +555,15 @@ public function process($data, Context $options, $path = '#', $result = null)
542555 if ($ additionalItems instanceof Schema) {
543556 $ result [$ key ] = $ additionalItems ->process ($ value , $ options , $ path . '-> ' . $ pathItems
544557 . '[ ' . $ index . '] ' );
545- } elseif ($ additionalItems === false ) {
558+ } elseif (! $ options -> skipValidation && $ additionalItems === false ) {
546559 $ this ->fail (new ArrayException ('Unexpected array item ' ), $ path );
547560 }
548561 }
549562 ++$ index ;
550563 }
551564 }
552565
553- if ($ this ->uniqueItems ) {
566+ if (! $ options -> skipValidation && $ this ->uniqueItems ) {
554567 if (!UniqueItems::isValid ($ data )) {
555568 $ this ->fail (new ArrayException ('Array is not unique ' ), $ path );
556569 }
0 commit comments