@@ -58,39 +58,39 @@ function getDraftToUse(localDraft, jsonSchemaDialect) {
58
58
* @returns {Array } Filtered mismatches after removing composite schema mismatches for valid data
59
59
*/
60
60
function filterCompositeSchemaErrors ( schema , validationMismatches ) {
61
- const compositeSchemaKeywords = [ 'anyOf' , 'oneOf' ] ,
62
- compositeSchemaKeyword = compositeSchemaKeywords [ 0 ] ,
63
- compositeSchemaMismatches = _ . filter ( validationMismatches , ( validationMismatch ) => {
61
+ _ . forEach ( [ 'anyOf' , 'oneOf' ] , ( compositeSchemaKeyword ) => {
62
+ const compositeSchemaMismatches = _ . filter ( validationMismatches , ( validationMismatch ) => {
64
63
return validationMismatch . keyword === compositeSchemaKeyword &&
65
64
_ . endsWith ( validationMismatch . schemaPath , compositeSchemaKeyword ) ;
66
65
} ) ;
67
66
68
- _ . forEach ( compositeSchemaMismatches , ( compositeSchemaMismatch ) => {
69
- let compositeSchemaMismatchPath = compositeSchemaMismatch . schemaPath ,
70
- schemaDataPath = formatDataPath ( formatSchemaPathFromAJVErrorToConvertToDataPath ( compositeSchemaMismatchPath ) ) ,
71
- schemaToUse = schemaDataPath ? _ . get ( schema , schemaDataPath ) : schema ,
72
- isCompositeSchemaValid = false ;
67
+ _ . forEach ( compositeSchemaMismatches , ( compositeSchemaMismatch ) => {
68
+ let compositeSchemaMismatchPath = compositeSchemaMismatch . schemaPath ,
69
+ schemaDataPath = formatDataPath ( formatSchemaPathFromAJVErrorToConvertToDataPath ( compositeSchemaMismatchPath ) ) ,
70
+ schemaToUse = schemaDataPath ? _ . get ( schema , schemaDataPath ) : schema ,
71
+ isCompositeSchemaValid = false ;
73
72
74
- if ( ! _ . isArray ( schemaToUse ) ) {
75
- return false ;
76
- }
73
+ if ( ! _ . isArray ( schemaToUse ) ) {
74
+ return false ;
75
+ }
77
76
78
- for ( let index = 0 ; index < schemaToUse . length ; index ++ ) {
79
- const isCurrentElementInvalid = _ . some ( validationMismatches , ( mismatch ) => {
80
- return _ . startsWith ( mismatch . schemaPath , compositeSchemaMismatchPath + `/${ index } ` ) ;
81
- } ) ;
77
+ for ( let index = 0 ; index < schemaToUse . length ; index ++ ) {
78
+ const isCurrentElementInvalid = _ . some ( validationMismatches , ( mismatch ) => {
79
+ return _ . startsWith ( mismatch . schemaPath , compositeSchemaMismatchPath + `/${ index } ` ) ;
80
+ } ) ;
82
81
83
- if ( ! isCurrentElementInvalid ) {
84
- isCompositeSchemaValid = true ;
85
- break ;
82
+ if ( ! isCurrentElementInvalid ) {
83
+ isCompositeSchemaValid = true ;
84
+ break ;
85
+ }
86
86
}
87
- }
88
87
89
- if ( isCompositeSchemaValid ) {
90
- validationMismatches = _ . reject ( validationMismatches , ( mismatch ) => {
91
- return _ . startsWith ( mismatch . schemaPath , compositeSchemaMismatchPath ) ;
92
- } ) ;
93
- }
88
+ if ( isCompositeSchemaValid ) {
89
+ validationMismatches = _ . reject ( validationMismatches , ( mismatch ) => {
90
+ return _ . startsWith ( mismatch . schemaPath , compositeSchemaMismatchPath ) ;
91
+ } ) ;
92
+ }
93
+ } ) ;
94
94
} ) ;
95
95
96
96
return validationMismatches ;
0 commit comments