Skip to content

Commit a227f7b

Browse files
committed
Rename ValidatorTypeCode to Keywords
1 parent 0594786 commit a227f7b

File tree

69 files changed

+206
-206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+206
-206
lines changed

src/main/java/com/networknt/schema/Schema.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import com.networknt.schema.keyword.DiscriminatorValidator;
3535
import com.networknt.schema.keyword.KeywordValidator;
3636
import com.networknt.schema.keyword.TypeValidator;
37-
import com.networknt.schema.keyword.ValidatorTypeCode;
37+
import com.networknt.schema.keyword.Keywords;
3838
import com.networknt.schema.utils.JsonNodes;
3939

4040
/**
@@ -186,13 +186,13 @@ private static SchemaLocation resolve(SchemaLocation schemaLocation, JsonNode sc
186186
if (!validator.validate(id, rootSchema, schemaLocation, result, schemaContext)) {
187187
SchemaLocation idSchemaLocation = schemaLocation.append(schemaContext.getDialect().getIdKeyword());
188188
Error error = Error.builder()
189-
.messageKey(ValidatorTypeCode.ID.getValue()).keyword(ValidatorTypeCode.ID.getValue())
189+
.messageKey(Keywords.ID.getValue()).keyword(Keywords.ID.getValue())
190190
.instanceLocation(idSchemaLocation.getFragment())
191191
.arguments(id, schemaContext.getDialect().getIdKeyword(), idSchemaLocation)
192192
.schemaLocation(idSchemaLocation)
193193
.schemaNode(schemaNode)
194194
.messageFormatter(args -> schemaContext.getSchemaRegistryConfig().getMessageSource().getMessage(
195-
ValidatorTypeCode.ID.getValue(), schemaContext.getSchemaRegistryConfig().getLocale(), args))
195+
Keywords.ID.getValue(), schemaContext.getSchemaRegistryConfig().getLocale(), args))
196196
.build();
197197
throw new InvalidSchemaException(error);
198198
}
@@ -506,7 +506,7 @@ public Schema getSubSchema(NodePath fragment) {
506506
}
507507
if (found == null) {
508508
Error error = Error.builder()
509-
.keyword(ValidatorTypeCode.REF.getValue()).messageKey("internal.unresolvedRef")
509+
.keyword(Keywords.REF.getValue()).messageKey("internal.unresolvedRef")
510510
.message("Reference {0} cannot be resolved")
511511
.instanceLocation(schemaLocation.getFragment())
512512
.schemaLocation(schemaLocation)

src/main/java/com/networknt/schema/Vocabulary.java

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import com.networknt.schema.keyword.AnnotationKeyword;
2424
import com.networknt.schema.keyword.Keyword;
2525
import com.networknt.schema.keyword.NonValidationKeyword;
26-
import com.networknt.schema.keyword.ValidatorTypeCode;
26+
import com.networknt.schema.keyword.Keywords;
2727

2828
/**
2929
* Represents a vocabulary in meta-schema.
@@ -35,75 +35,75 @@ public class Vocabulary {
3535
// 2019-09
3636
public static final Vocabulary DRAFT_2019_09_CORE = new Vocabulary("https://json-schema.org/draft/2019-09/vocab/core",
3737
new NonValidationKeyword("$id"), new NonValidationKeyword("$schema"), new NonValidationKeyword("$anchor"),
38-
ValidatorTypeCode.REF, ValidatorTypeCode.RECURSIVE_REF, new NonValidationKeyword("$recursiveAnchor"),
38+
Keywords.REF, Keywords.RECURSIVE_REF, new NonValidationKeyword("$recursiveAnchor"),
3939
new NonValidationKeyword("$vocabulary"), new NonValidationKeyword("$comment"),
4040
new NonValidationKeyword("$defs"));
4141
public static final Vocabulary DRAFT_2019_09_APPLICATOR = new Vocabulary(
4242
"https://json-schema.org/draft/2019-09/vocab/applicator", new NonValidationKeyword("additionalItems"),
43-
ValidatorTypeCode.UNEVALUATED_ITEMS, ValidatorTypeCode.ITEMS, ValidatorTypeCode.CONTAINS,
44-
ValidatorTypeCode.ADDITIONAL_PROPERTIES, ValidatorTypeCode.UNEVALUATED_PROPERTIES,
45-
ValidatorTypeCode.PROPERTIES, ValidatorTypeCode.PATTERN_PROPERTIES, ValidatorTypeCode.DEPENDENT_SCHEMAS,
46-
ValidatorTypeCode.PROPERTYNAMES, ValidatorTypeCode.IF_THEN_ELSE, new NonValidationKeyword("then"),
47-
new NonValidationKeyword("else"), ValidatorTypeCode.ALL_OF, ValidatorTypeCode.ANY_OF,
48-
ValidatorTypeCode.ONE_OF, ValidatorTypeCode.NOT);
43+
Keywords.UNEVALUATED_ITEMS, Keywords.ITEMS, Keywords.CONTAINS,
44+
Keywords.ADDITIONAL_PROPERTIES, Keywords.UNEVALUATED_PROPERTIES,
45+
Keywords.PROPERTIES, Keywords.PATTERN_PROPERTIES, Keywords.DEPENDENT_SCHEMAS,
46+
Keywords.PROPERTYNAMES, Keywords.IF_THEN_ELSE, new NonValidationKeyword("then"),
47+
new NonValidationKeyword("else"), Keywords.ALL_OF, Keywords.ANY_OF,
48+
Keywords.ONE_OF, Keywords.NOT);
4949
public static final Vocabulary DRAFT_2019_09_VALIDATION = new Vocabulary(
50-
"https://json-schema.org/draft/2019-09/vocab/validation", ValidatorTypeCode.MULTIPLE_OF,
51-
ValidatorTypeCode.MAXIMUM, ValidatorTypeCode.EXCLUSIVE_MAXIMUM, ValidatorTypeCode.MINIMUM,
52-
ValidatorTypeCode.EXCLUSIVE_MINIMUM, ValidatorTypeCode.MAX_LENGTH, ValidatorTypeCode.MIN_LENGTH,
53-
ValidatorTypeCode.PATTERN, ValidatorTypeCode.MAX_ITEMS, ValidatorTypeCode.MIN_ITEMS,
54-
ValidatorTypeCode.UNIQUE_ITEMS, ValidatorTypeCode.MAX_CONTAINS, ValidatorTypeCode.MIN_CONTAINS,
55-
ValidatorTypeCode.MAX_PROPERTIES, ValidatorTypeCode.MIN_PROPERTIES, ValidatorTypeCode.REQUIRED,
56-
ValidatorTypeCode.DEPENDENT_REQUIRED, ValidatorTypeCode.CONST, ValidatorTypeCode.ENUM,
57-
ValidatorTypeCode.TYPE);
50+
"https://json-schema.org/draft/2019-09/vocab/validation", Keywords.MULTIPLE_OF,
51+
Keywords.MAXIMUM, Keywords.EXCLUSIVE_MAXIMUM, Keywords.MINIMUM,
52+
Keywords.EXCLUSIVE_MINIMUM, Keywords.MAX_LENGTH, Keywords.MIN_LENGTH,
53+
Keywords.PATTERN, Keywords.MAX_ITEMS, Keywords.MIN_ITEMS,
54+
Keywords.UNIQUE_ITEMS, Keywords.MAX_CONTAINS, Keywords.MIN_CONTAINS,
55+
Keywords.MAX_PROPERTIES, Keywords.MIN_PROPERTIES, Keywords.REQUIRED,
56+
Keywords.DEPENDENT_REQUIRED, Keywords.CONST, Keywords.ENUM,
57+
Keywords.TYPE);
5858
public static final Vocabulary DRAFT_2019_09_META_DATA = new Vocabulary(
5959
"https://json-schema.org/draft/2019-09/vocab/meta-data", new AnnotationKeyword("title"),
6060
new AnnotationKeyword("description"), new AnnotationKeyword("default"), new AnnotationKeyword("deprecated"),
61-
ValidatorTypeCode.READ_ONLY, ValidatorTypeCode.WRITE_ONLY, new AnnotationKeyword("examples"));
61+
Keywords.READ_ONLY, Keywords.WRITE_ONLY, new AnnotationKeyword("examples"));
6262
public static final Vocabulary DRAFT_2019_09_FORMAT = new Vocabulary("https://json-schema.org/draft/2019-09/vocab/format",
63-
ValidatorTypeCode.FORMAT);
63+
Keywords.FORMAT);
6464
public static final Vocabulary DRAFT_2019_09_CONTENT = new Vocabulary(
6565
"https://json-schema.org/draft/2019-09/vocab/content", new AnnotationKeyword("contentMediaType"),
6666
new AnnotationKeyword("contentEncoding"), new AnnotationKeyword("contentSchema"));
6767

6868
// 2020-12
6969
public static final Vocabulary DRAFT_2020_12_CORE = new Vocabulary("https://json-schema.org/draft/2020-12/vocab/core",
70-
new NonValidationKeyword("$id"), new NonValidationKeyword("$schema"), ValidatorTypeCode.REF,
71-
new NonValidationKeyword("$anchor"), ValidatorTypeCode.DYNAMIC_REF,
70+
new NonValidationKeyword("$id"), new NonValidationKeyword("$schema"), Keywords.REF,
71+
new NonValidationKeyword("$anchor"), Keywords.DYNAMIC_REF,
7272
new NonValidationKeyword("$dynamicAnchor"), new NonValidationKeyword("$vocabulary"),
7373
new NonValidationKeyword("$comment"), new NonValidationKeyword("$defs"));
7474
public static final Vocabulary DRAFT_2020_12_APPLICATOR = new Vocabulary(
75-
"https://json-schema.org/draft/2020-12/vocab/applicator", ValidatorTypeCode.PREFIX_ITEMS,
76-
ValidatorTypeCode.ITEMS_202012, ValidatorTypeCode.CONTAINS, ValidatorTypeCode.ADDITIONAL_PROPERTIES,
77-
ValidatorTypeCode.PROPERTIES, ValidatorTypeCode.PATTERN_PROPERTIES, ValidatorTypeCode.DEPENDENT_SCHEMAS,
78-
ValidatorTypeCode.PROPERTYNAMES, ValidatorTypeCode.IF_THEN_ELSE, new NonValidationKeyword("then"),
79-
new NonValidationKeyword("else"), ValidatorTypeCode.ALL_OF, ValidatorTypeCode.ANY_OF,
80-
ValidatorTypeCode.ONE_OF, ValidatorTypeCode.NOT);
75+
"https://json-schema.org/draft/2020-12/vocab/applicator", Keywords.PREFIX_ITEMS,
76+
Keywords.ITEMS_202012, Keywords.CONTAINS, Keywords.ADDITIONAL_PROPERTIES,
77+
Keywords.PROPERTIES, Keywords.PATTERN_PROPERTIES, Keywords.DEPENDENT_SCHEMAS,
78+
Keywords.PROPERTYNAMES, Keywords.IF_THEN_ELSE, new NonValidationKeyword("then"),
79+
new NonValidationKeyword("else"), Keywords.ALL_OF, Keywords.ANY_OF,
80+
Keywords.ONE_OF, Keywords.NOT);
8181
public static final Vocabulary DRAFT_2020_12_UNEVALUATED = new Vocabulary(
82-
"https://json-schema.org/draft/2020-12/vocab/unevaluated", ValidatorTypeCode.UNEVALUATED_ITEMS,
83-
ValidatorTypeCode.UNEVALUATED_PROPERTIES);
82+
"https://json-schema.org/draft/2020-12/vocab/unevaluated", Keywords.UNEVALUATED_ITEMS,
83+
Keywords.UNEVALUATED_PROPERTIES);
8484
public static final Vocabulary DRAFT_2020_12_VALIDATION = new Vocabulary(
85-
"https://json-schema.org/draft/2020-12/vocab/validation", ValidatorTypeCode.TYPE, ValidatorTypeCode.CONST,
86-
ValidatorTypeCode.ENUM, ValidatorTypeCode.MULTIPLE_OF, ValidatorTypeCode.MAXIMUM,
87-
ValidatorTypeCode.EXCLUSIVE_MAXIMUM, ValidatorTypeCode.MINIMUM, ValidatorTypeCode.EXCLUSIVE_MINIMUM,
88-
ValidatorTypeCode.MAX_LENGTH, ValidatorTypeCode.MIN_LENGTH, ValidatorTypeCode.PATTERN,
89-
ValidatorTypeCode.MAX_ITEMS, ValidatorTypeCode.MIN_ITEMS, ValidatorTypeCode.UNIQUE_ITEMS,
90-
ValidatorTypeCode.MAX_CONTAINS, ValidatorTypeCode.MIN_CONTAINS, ValidatorTypeCode.MAX_PROPERTIES,
91-
ValidatorTypeCode.MIN_PROPERTIES, ValidatorTypeCode.REQUIRED, ValidatorTypeCode.DEPENDENT_REQUIRED);
85+
"https://json-schema.org/draft/2020-12/vocab/validation", Keywords.TYPE, Keywords.CONST,
86+
Keywords.ENUM, Keywords.MULTIPLE_OF, Keywords.MAXIMUM,
87+
Keywords.EXCLUSIVE_MAXIMUM, Keywords.MINIMUM, Keywords.EXCLUSIVE_MINIMUM,
88+
Keywords.MAX_LENGTH, Keywords.MIN_LENGTH, Keywords.PATTERN,
89+
Keywords.MAX_ITEMS, Keywords.MIN_ITEMS, Keywords.UNIQUE_ITEMS,
90+
Keywords.MAX_CONTAINS, Keywords.MIN_CONTAINS, Keywords.MAX_PROPERTIES,
91+
Keywords.MIN_PROPERTIES, Keywords.REQUIRED, Keywords.DEPENDENT_REQUIRED);
9292
public static final Vocabulary DRAFT_2020_12_META_DATA = new Vocabulary(
9393
"https://json-schema.org/draft/2020-12/vocab/meta-data", new AnnotationKeyword("title"),
9494
new AnnotationKeyword("description"), new AnnotationKeyword("default"), new AnnotationKeyword("deprecated"),
95-
ValidatorTypeCode.READ_ONLY, ValidatorTypeCode.WRITE_ONLY, new AnnotationKeyword("examples"));
95+
Keywords.READ_ONLY, Keywords.WRITE_ONLY, new AnnotationKeyword("examples"));
9696
public static final Vocabulary DRAFT_2020_12_FORMAT_ANNOTATION = new Vocabulary(
97-
"https://json-schema.org/draft/2020-12/vocab/format-annotation", ValidatorTypeCode.FORMAT);
97+
"https://json-schema.org/draft/2020-12/vocab/format-annotation", Keywords.FORMAT);
9898
public static final Vocabulary DRAFT_2020_12_FORMAT_ASSERTION = new Vocabulary(
99-
"https://json-schema.org/draft/2020-12/vocab/format-assertion", ValidatorTypeCode.FORMAT);
99+
"https://json-schema.org/draft/2020-12/vocab/format-assertion", Keywords.FORMAT);
100100
public static final Vocabulary DRAFT_2020_12_CONTENT = new Vocabulary(
101101
"https://json-schema.org/draft/2020-12/vocab/content", new AnnotationKeyword("contentEncoding"),
102102
new AnnotationKeyword("contentMediaType"), new AnnotationKeyword("contentSchema"));
103103

104104
// OpenAPI 3.1
105105
public static final Vocabulary OPENAPI_3_1_BASE = new Vocabulary("https://spec.openapis.org/oas/3.1/vocab/base",
106-
new AnnotationKeyword("example"), ValidatorTypeCode.DISCRIMINATOR, new AnnotationKeyword("externalDocs"),
106+
new AnnotationKeyword("example"), Keywords.DISCRIMINATOR, new AnnotationKeyword("externalDocs"),
107107
new AnnotationKeyword("xml"));
108108

109109
private final String iri;

src/main/java/com/networknt/schema/dialect/Dialect.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import com.networknt.schema.keyword.KeywordFactory;
3535
import com.networknt.schema.keyword.KeywordValidator;
3636
import com.networknt.schema.keyword.UnknownKeywordFactory;
37-
import com.networknt.schema.keyword.ValidatorTypeCode;
37+
import com.networknt.schema.keyword.Keywords;
3838
import com.networknt.schema.utils.StringUtils;
3939
import org.slf4j.Logger;
4040
import org.slf4j.LoggerFactory;
@@ -93,8 +93,8 @@ private Map<String, Keyword> createKeywordsMap(Map<String, Keyword> kwords, Map<
9393
for (Map.Entry<String, Keyword> type : kwords.entrySet()) {
9494
String keywordName = type.getKey();
9595
Keyword keyword = type.getValue();
96-
if (ValidatorTypeCode.FORMAT.getValue().equals(keywordName)) {
97-
if (!(keyword instanceof FormatKeyword) && !ValidatorTypeCode.FORMAT.equals(keyword)) {
96+
if (Keywords.FORMAT.getValue().equals(keywordName)) {
97+
if (!(keyword instanceof FormatKeyword) && !Keywords.FORMAT.equals(keyword)) {
9898
throw new IllegalArgumentException("Overriding the keyword 'format' is not supported. Use the formatKeywordFactory and extend the FormatKeyword.");
9999
}
100100
// Indicate that the format keyword needs to be created
@@ -455,9 +455,9 @@ public KeywordValidator newValidator(SchemaContext schemaContext, SchemaLocation
455455
if (schemaContext.isNullableKeywordEnabled() && "nullable".equals(keyword)) {
456456
return null;
457457
}
458-
if (ValidatorTypeCode.DISCRIMINATOR.getValue().equals(keyword)
458+
if (Keywords.DISCRIMINATOR.getValue().equals(keyword)
459459
&& schemaContext.isDiscriminatorKeywordEnabled()) {
460-
return ValidatorTypeCode.DISCRIMINATOR.newValidator(schemaLocation, evaluationPath, schemaNode,
460+
return Keywords.DISCRIMINATOR.newValidator(schemaLocation, evaluationPath, schemaNode,
461461
parentSchema, schemaContext);
462462
}
463463
kw = this.builder.unknownKeywordFactory != null

src/main/java/com/networknt/schema/dialect/Draft201909.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import com.networknt.schema.Formats;
88
import com.networknt.schema.SpecificationVersion;
99
import com.networknt.schema.keyword.NonValidationKeyword;
10-
import com.networknt.schema.keyword.ValidatorTypeCode;
10+
import com.networknt.schema.keyword.Keywords;
1111

1212
/**
1313
* Draft 2019-09 dialect.
@@ -35,7 +35,7 @@ private static class Holder {
3535
.specificationVersion(SpecificationVersion.DRAFT_2019_09)
3636
.idKeyword(ID_KEYWORD)
3737
.formats(Formats.DEFAULT)
38-
.keywords(ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_2019_09))
38+
.keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_2019_09))
3939
// keywords that may validly exist, but have no validation aspect to them
4040
.keywords(Collections.singletonList(
4141
new NonValidationKeyword("definitions")

src/main/java/com/networknt/schema/dialect/Draft202012.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import com.networknt.schema.Formats;
88
import com.networknt.schema.SpecificationVersion;
99
import com.networknt.schema.keyword.NonValidationKeyword;
10-
import com.networknt.schema.keyword.ValidatorTypeCode;
10+
import com.networknt.schema.keyword.Keywords;
1111

1212
/**
1313
* Draft 2020-12 dialect.
@@ -36,7 +36,7 @@ private static class Holder {
3636
.specificationVersion(SpecificationVersion.DRAFT_2020_12)
3737
.idKeyword(ID_KEYWORD)
3838
.formats(Formats.DEFAULT)
39-
.keywords(ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_2020_12))
39+
.keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_2020_12))
4040
// keywords that may validly exist, but have no validation aspect to them
4141
.keywords(Collections.singletonList(
4242
new NonValidationKeyword("definitions")

src/main/java/com/networknt/schema/dialect/Draft4.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.networknt.schema.SpecificationVersion;
77
import com.networknt.schema.keyword.AnnotationKeyword;
88
import com.networknt.schema.keyword.NonValidationKeyword;
9-
import com.networknt.schema.keyword.ValidatorTypeCode;
9+
import com.networknt.schema.keyword.Keywords;
1010

1111
/**
1212
* Draft 4 dialect.
@@ -22,7 +22,7 @@ private static class Holder {
2222
.specificationVersion(SpecificationVersion.DRAFT_4)
2323
.idKeyword(ID_KEYWORD)
2424
.formats(Formats.DEFAULT)
25-
.keywords(ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_4))
25+
.keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_4))
2626
// keywords that may validly exist, but have no validation aspect to them
2727
.keywords(Arrays.asList(
2828
new NonValidationKeyword("$schema"),

src/main/java/com/networknt/schema/dialect/Draft6.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.networknt.schema.SpecificationVersion;
77
import com.networknt.schema.keyword.AnnotationKeyword;
88
import com.networknt.schema.keyword.NonValidationKeyword;
9-
import com.networknt.schema.keyword.ValidatorTypeCode;
9+
import com.networknt.schema.keyword.Keywords;
1010

1111
/**
1212
* Draft 6 dialect.
@@ -23,7 +23,7 @@ private static class Holder {
2323
.specificationVersion(SpecificationVersion.DRAFT_6)
2424
.idKeyword(ID_KEYWORD)
2525
.formats(Formats.DEFAULT)
26-
.keywords(ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_6))
26+
.keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_6))
2727
// keywords that may validly exist, but have no validation aspect to them
2828
.keywords(Arrays.asList(
2929
new NonValidationKeyword("$schema"),

src/main/java/com/networknt/schema/dialect/Draft7.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.networknt.schema.SpecificationVersion;
77
import com.networknt.schema.keyword.AnnotationKeyword;
88
import com.networknt.schema.keyword.NonValidationKeyword;
9-
import com.networknt.schema.keyword.ValidatorTypeCode;
9+
import com.networknt.schema.keyword.Keywords;
1010

1111
/**
1212
* Draft 7 dialect.
@@ -22,7 +22,7 @@ private static class Holder {
2222
.specificationVersion(SpecificationVersion.DRAFT_7)
2323
.idKeyword(ID_KEYWORD)
2424
.formats(Formats.DEFAULT)
25-
.keywords(ValidatorTypeCode.getKeywords(SpecificationVersion.DRAFT_7))
25+
.keywords(Keywords.getKeywords(SpecificationVersion.DRAFT_7))
2626
// keywords that may validly exist, but have no validation aspect to them
2727
.keywords(Arrays.asList(
2828
new NonValidationKeyword("$schema"),

0 commit comments

Comments
 (0)