@@ -12,36 +12,43 @@ const containsErrorHandler = async (normalizedErrors, instance, localization) =>
1212 /** @type ErrorObject[] */
1313 const errors = [ ] ;
1414
15- for ( const schemaLocation in normalizedErrors [ "https://json-schema.org/keyword/contains" ] ) {
16- if ( normalizedErrors [ "https://json-schema.org/keyword/contains" ] [ schemaLocation ] == true ) {
17- continue ;
15+ const keywordUris = [
16+ "https://json-schema.org/keyword/contains" ,
17+ "https://json-schema.org/keyword/draft-06/contains"
18+ ] ;
19+
20+ for ( const keywordUri of keywordUris ) {
21+ for ( const schemaLocation in normalizedErrors [ keywordUri ] ) {
22+ if ( normalizedErrors [ keywordUri ] [ schemaLocation ] == true ) {
23+ continue ;
24+ }
25+
26+ /** @type string[] */
27+ const schemaLocations = [ schemaLocation ] ;
28+
29+ /** @type ContainsRange */
30+ const range = { } ;
31+
32+ for ( const minContainsLocation in normalizedErrors [ "https://json-schema.org/keyword/minContains" ] ) {
33+ const minContainsNode = await getSchema ( minContainsLocation ) ;
34+ const minContains = /** @type number */ ( Schema . value ( minContainsNode ) ) ;
35+ range . minContains = Math . max ( range . minContains ?? - 1 , minContains ) ;
36+ schemaLocations . push ( minContainsLocation ) ;
37+ }
38+
39+ for ( const maxContainsLocation in normalizedErrors [ "https://json-schema.org/keyword/maxContains" ] ) {
40+ const maxContainsNode = await getSchema ( maxContainsLocation ) ;
41+ const maxContains = /** @type number */ ( Schema . value ( maxContainsNode ) ) ;
42+ range . maxContains = Math . min ( range . maxContains ?? Number . MAX_VALUE , maxContains ) ;
43+ schemaLocations . push ( maxContainsLocation ) ;
44+ }
45+
46+ errors . push ( {
47+ message : localization . getContainsErrorMessage ( range ) ,
48+ instanceLocation : Instance . uri ( instance ) ,
49+ schemaLocations : schemaLocations
50+ } ) ;
1851 }
19-
20- /** @type string[] */
21- const schemaLocations = [ schemaLocation ] ;
22-
23- /** @type ContainsRange */
24- const range = { } ;
25-
26- for ( const minContainsLocation in normalizedErrors [ "https://json-schema.org/keyword/minContains" ] ) {
27- const minContainsNode = await getSchema ( minContainsLocation ) ;
28- const minContains = /** @type number */ ( Schema . value ( minContainsNode ) ) ;
29- range . minContains = Math . max ( range . minContains ?? - 1 , minContains ) ;
30- schemaLocations . push ( minContainsLocation ) ;
31- }
32-
33- for ( const maxContainsLocation in normalizedErrors [ "https://json-schema.org/keyword/maxContains" ] ) {
34- const maxContainsNode = await getSchema ( maxContainsLocation ) ;
35- const maxContains = /** @type number */ ( Schema . value ( maxContainsNode ) ) ;
36- range . maxContains = Math . min ( range . maxContains ?? Number . MAX_VALUE , maxContains ) ;
37- schemaLocations . push ( maxContainsLocation ) ;
38- }
39-
40- errors . push ( {
41- message : localization . getContainsErrorMessage ( range ) ,
42- instanceLocation : Instance . uri ( instance ) ,
43- schemaLocations : schemaLocations
44- } ) ;
4552 }
4653
4754 return errors ;
0 commit comments