diff --git a/src/main/java/com/networknt/schema/AdditionalPropertiesValidator.java b/src/main/java/com/networknt/schema/AdditionalPropertiesValidator.java index ce05c5e66..2cca133ef 100644 --- a/src/main/java/com/networknt/schema/AdditionalPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/AdditionalPropertiesValidator.java @@ -113,9 +113,9 @@ public Set validate(ExecutionContext executionContext, JsonNo errors = new LinkedHashSet<>(); } errors.add(message().instanceNode(node).property(pname) - .instanceLocation(instanceLocation.append(pname)) + .instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(pname).build()); + .failFast(executionContext.isFailFast()).arguments(pname).build()); } else { if (additionalPropertiesSchema != null) { ValidatorState state = executionContext.getValidatorState(); diff --git a/src/main/java/com/networknt/schema/AnyOfValidator.java b/src/main/java/com/networknt/schema/AnyOfValidator.java index f99cb7925..ced603e7c 100644 --- a/src/main/java/com/networknt/schema/AnyOfValidator.java +++ b/src/main/java/com/networknt/schema/AnyOfValidator.java @@ -69,9 +69,9 @@ public Set validate(ExecutionContext executionContext, JsonNo int numberOfValidSubSchemas = 0; try { // Save flag as nested schema evaluation shouldn't trigger fail fast - boolean failFast = executionContext.getExecutionConfig().isFailFast(); + boolean failFast = executionContext.isFailFast(); try { - executionContext.getExecutionConfig().setFailFast(false); + executionContext.setFailFast(false); for (JsonSchema schema : this.schemas) { Set errors = Collections.emptySet(); state.setMatchedNode(initialHasMatchedNode); @@ -104,7 +104,7 @@ public Set validate(ExecutionContext executionContext, JsonNo } if (errors.isEmpty() && (!this.validationContext.getConfig().isOpenAPI3StyleDiscriminators()) - && canShortCircuit()) { + && canShortCircuit() && canShortCircuit(executionContext)) { // Clear all errors. allErrors.clear(); // return empty errors. @@ -115,7 +115,7 @@ && canShortCircuit()) { allErrors.addAll(errors); allErrors.add(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()) + .failFast(executionContext.isFailFast()) .arguments(DISCRIMINATOR_REMARK).build()); } else { // Clear all errors. @@ -128,7 +128,7 @@ && canShortCircuit()) { } } finally { // Restore flag - executionContext.getExecutionConfig().setFailFast(failFast); + executionContext.setFailFast(failFast); } // determine only those errors which are NOT of type "required" property missing @@ -174,7 +174,24 @@ public Set walk(ExecutionContext executionContext, JsonNode n } return new LinkedHashSet<>(); } - + + /** + * If annotation collection is enabled cannot short circuit. + * + * @see anyOf + * @param executionContext the execution context + * @return true if can short circuit + */ + protected boolean canShortCircuit(ExecutionContext executionContext) { + return !executionContext.getExecutionConfig().isAnnotationCollectionEnabled(); + } + + /** + * If annotations are require for evaluation cannot short circuit. + * + * @return true if can short circuit + */ protected boolean canShortCircuit() { if (this.canShortCircuit == null) { boolean canShortCircuit = true; diff --git a/src/main/java/com/networknt/schema/BaseJsonValidator.java b/src/main/java/com/networknt/schema/BaseJsonValidator.java index f645a7eef..0f52a9040 100644 --- a/src/main/java/com/networknt/schema/BaseJsonValidator.java +++ b/src/main/java/com/networknt/schema/BaseJsonValidator.java @@ -31,8 +31,6 @@ public abstract class BaseJsonValidator extends ValidationMessageHandler implements JsonValidator { protected final boolean suppressSubSchemaRetrieval; - protected final ApplyDefaultsStrategy applyDefaultsStrategy; - private final PathType pathType; protected final JsonNode schemaNode; @@ -59,13 +57,6 @@ public BaseJsonValidator(SchemaLocation schemaLocation, JsonNodePath evaluationP this.validationContext = validationContext; this.schemaNode = schemaNode; this.suppressSubSchemaRetrieval = suppressSubSchemaRetrieval; - this.applyDefaultsStrategy = (validationContext != null && validationContext.getConfig() != null - && validationContext.getConfig().getApplyDefaultsStrategy() != null) - ? validationContext.getConfig().getApplyDefaultsStrategy() - : ApplyDefaultsStrategy.EMPTY_APPLY_DEFAULTS_STRATEGY; - this.pathType = (validationContext != null && validationContext.getConfig() != null - && validationContext.getConfig().getPathType() != null) ? validationContext.getConfig().getPathType() - : PathType.DEFAULT; } /** @@ -76,8 +67,6 @@ public BaseJsonValidator(SchemaLocation schemaLocation, JsonNodePath evaluationP protected BaseJsonValidator(BaseJsonValidator copy) { super(copy); this.suppressSubSchemaRetrieval = copy.suppressSubSchemaRetrieval; - this.applyDefaultsStrategy = copy.applyDefaultsStrategy; - this.pathType = copy.pathType; this.schemaNode = copy.schemaNode; this.validationContext = copy.validationContext; } @@ -307,7 +296,7 @@ protected void preloadJsonSchemas(final Collection schemas) { * @return The path. */ protected JsonNodePath atRoot() { - return new JsonNodePath(this.pathType); + return new JsonNodePath(this.validationContext.getConfig().getPathType()); } @Override diff --git a/src/main/java/com/networknt/schema/ConstValidator.java b/src/main/java/com/networknt/schema/ConstValidator.java index 8c8151f24..96385dc16 100644 --- a/src/main/java/com/networknt/schema/ConstValidator.java +++ b/src/main/java/com/networknt/schema/ConstValidator.java @@ -41,7 +41,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (schemaNode.decimalValue().compareTo(node.decimalValue()) != 0) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(schemaNode.asText()) + .failFast(executionContext.isFailFast()).arguments(schemaNode.asText()) .build()); } } else if (!schemaNode.equals(node)) { diff --git a/src/main/java/com/networknt/schema/ContainsValidator.java b/src/main/java/com/networknt/schema/ContainsValidator.java index 00c177e08..1ef019905 100644 --- a/src/main/java/com/networknt/schema/ContainsValidator.java +++ b/src/main/java/com/networknt/schema/ContainsValidator.java @@ -80,9 +80,9 @@ public Set validate(ExecutionContext executionContext, JsonNo List indexes = new ArrayList<>(); // for the annotation if (null != this.schema && node.isArray()) { // Save flag as nested schema evaluation shouldn't trigger fail fast - boolean failFast = executionContext.getExecutionConfig().isFailFast(); + boolean failFast = executionContext.isFailFast(); try { - executionContext.getExecutionConfig().setFailFast(false); + executionContext.setFailFast(false); for (JsonNode n : node) { JsonNodePath path = instanceLocation.append(i); if (this.schema.validate(executionContext, n, rootNode, path).isEmpty()) { @@ -93,7 +93,7 @@ public Set validate(ExecutionContext executionContext, JsonNo } } finally { // Restore flag - executionContext.getExecutionConfig().setFailFast(failFast); + executionContext.setFailFast(failFast); } int m = 1; // default to 1 if "min" not specified if (this.min != null) { @@ -102,13 +102,13 @@ public Set validate(ExecutionContext executionContext, JsonNo if (actual < m) { results = boundsViolated(isMinV201909 ? ValidatorTypeCode.MIN_CONTAINS : ValidatorTypeCode.CONTAINS, executionContext.getExecutionConfig().getLocale(), - executionContext.getExecutionConfig().isFailFast(), node, instanceLocation, m); + executionContext.isFailFast(), node, instanceLocation, m); } if (this.max != null && actual > this.max) { results = boundsViolated(isMinV201909 ? ValidatorTypeCode.MAX_CONTAINS : ValidatorTypeCode.CONTAINS, executionContext.getExecutionConfig().getLocale(), - executionContext.getExecutionConfig().isFailFast(), node, instanceLocation, this.max); + executionContext.isFailFast(), node, instanceLocation, this.max); } } diff --git a/src/main/java/com/networknt/schema/ContentEncodingValidator.java b/src/main/java/com/networknt/schema/ContentEncodingValidator.java index 03a51c31f..11e79ea64 100644 --- a/src/main/java/com/networknt/schema/ContentEncodingValidator.java +++ b/src/main/java/com/networknt/schema/ContentEncodingValidator.java @@ -82,7 +82,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (!matches(node.asText())) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(this.contentEncoding) + .failFast(executionContext.isFailFast()).arguments(this.contentEncoding) .build()); } return Collections.emptySet(); diff --git a/src/main/java/com/networknt/schema/ContentMediaTypeValidator.java b/src/main/java/com/networknt/schema/ContentMediaTypeValidator.java index 7eecf1c3a..f4dd194ba 100644 --- a/src/main/java/com/networknt/schema/ContentMediaTypeValidator.java +++ b/src/main/java/com/networknt/schema/ContentMediaTypeValidator.java @@ -106,7 +106,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (!matches(node.asText())) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(this.contentMediaType) + .failFast(executionContext.isFailFast()).arguments(this.contentMediaType) .build()); } return Collections.emptySet(); diff --git a/src/main/java/com/networknt/schema/DependenciesValidator.java b/src/main/java/com/networknt/schema/DependenciesValidator.java index c36789511..5ecaddf33 100644 --- a/src/main/java/com/networknt/schema/DependenciesValidator.java +++ b/src/main/java/com/networknt/schema/DependenciesValidator.java @@ -75,7 +75,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (node.get(field) == null) { errors.add(message().instanceNode(node).property(pname).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()) + .failFast(executionContext.isFailFast()) .arguments(propertyDeps.toString()).build()); } } diff --git a/src/main/java/com/networknt/schema/DependentRequired.java b/src/main/java/com/networknt/schema/DependentRequired.java index dda8ec5ae..8350726b5 100644 --- a/src/main/java/com/networknt/schema/DependentRequired.java +++ b/src/main/java/com/networknt/schema/DependentRequired.java @@ -59,7 +59,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (node.get(field) == null) { errors.add(message().instanceNode(node).property(pname).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(field, pname) + .failFast(executionContext.isFailFast()).arguments(field, pname) .build()); } } diff --git a/src/main/java/com/networknt/schema/EnumValidator.java b/src/main/java/com/networknt/schema/EnumValidator.java index 1e088c648..582666db2 100644 --- a/src/main/java/com/networknt/schema/EnumValidator.java +++ b/src/main/java/com/networknt/schema/EnumValidator.java @@ -92,7 +92,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (!nodes.contains(node) && !( this.validationContext.getConfig().isTypeLoose() && isTypeLooseContainsInEnum(node))) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(error).build()); + .failFast(executionContext.isFailFast()).arguments(error).build()); } return Collections.emptySet(); diff --git a/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java b/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java index 88c1bde82..35db8ddf2 100644 --- a/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java +++ b/src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java @@ -108,7 +108,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (typedMaximum.crossesThreshold(node)) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()) + .failFast(executionContext.isFailFast()) .arguments(typedMaximum.thresholdValue()).build()); } return Collections.emptySet(); diff --git a/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java b/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java index a53a56b76..ab2568ff7 100644 --- a/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java +++ b/src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java @@ -115,7 +115,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (typedMinimum.crossesThreshold(node)) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()) + .failFast(executionContext.isFailFast()) .arguments(typedMinimum.thresholdValue()).build()); } return Collections.emptySet(); diff --git a/src/main/java/com/networknt/schema/ExecutionConfig.java b/src/main/java/com/networknt/schema/ExecutionConfig.java index e7a8aacb2..516241dcd 100644 --- a/src/main/java/com/networknt/schema/ExecutionConfig.java +++ b/src/main/java/com/networknt/schema/ExecutionConfig.java @@ -54,7 +54,7 @@ public class ExecutionConfig { * Determine if the validation execution can fail fast. */ private boolean failFast = false; - + /** * Gets the locale to use for formatting messages. * diff --git a/src/main/java/com/networknt/schema/ExecutionContext.java b/src/main/java/com/networknt/schema/ExecutionContext.java index 05becdd23..fc32d2fbb 100644 --- a/src/main/java/com/networknt/schema/ExecutionContext.java +++ b/src/main/java/com/networknt/schema/ExecutionContext.java @@ -31,6 +31,13 @@ public class ExecutionContext { private Stack discriminatorContexts = new Stack<>(); private JsonNodeAnnotations annotations = new JsonNodeAnnotations(); private JsonNodeResults results = new JsonNodeResults(); + + /** + * This is used during the execution to determine if the validator should fail fast. + *

+ * This valid is determined by the previous validator. + */ + private Boolean failFast = null; /** * Creates an execution context. @@ -111,7 +118,32 @@ public JsonNodeAnnotations getAnnotations() { public JsonNodeResults getResults() { return results; } - + + /** + * Determines if the validator should immediately throw a fail fast exception if + * an error has occurred. + *

+ * This defaults to the execution config fail fast at the start of the execution. + * + * @return true if fail fast + */ + public boolean isFailFast() { + if (this.failFast == null) { + this.failFast = getExecutionConfig().isFailFast(); + } + return failFast; + } + + /** + * Sets if the validator should immediately throw a fail fast exception if an + * error has occurred. + * + * @param failFast true to fail fast + */ + public void setFailFast(boolean failFast) { + this.failFast = failFast; + } + /** * Gets the validator state. * diff --git a/src/main/java/com/networknt/schema/FalseValidator.java b/src/main/java/com/networknt/schema/FalseValidator.java index 3fa2ba4b2..8018a76b0 100644 --- a/src/main/java/com/networknt/schema/FalseValidator.java +++ b/src/main/java/com/networknt/schema/FalseValidator.java @@ -28,8 +28,11 @@ public class FalseValidator extends BaseJsonValidator implements JsonValidator { private static final Logger logger = LoggerFactory.getLogger(FalseValidator.class); + private final String reason; + public FalseValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, final JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.FALSE, validationContext); + this.reason = this.evaluationPath.getParent().getName(-1); } public Set validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { @@ -37,6 +40,6 @@ public Set validate(ExecutionContext executionContext, JsonNo // For the false validator, it is always not valid return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).build()); + .failFast(executionContext.isFailFast()).arguments(reason).build()); } } diff --git a/src/main/java/com/networknt/schema/FormatValidator.java b/src/main/java/com/networknt/schema/FormatValidator.java index 9fa21b313..7e588d447 100644 --- a/src/main/java/com/networknt/schema/FormatValidator.java +++ b/src/main/java/com/networknt/schema/FormatValidator.java @@ -61,7 +61,7 @@ public Set validate(ExecutionContext executionContext, JsonNo // leading and trailing spaces errors.add(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()) + .failFast(executionContext.isFailFast()) .arguments(format.getName(), format.getErrorMessageDescription()).build()); } } else if(node.textValue().contains("%")) { diff --git a/src/main/java/com/networknt/schema/IfValidator.java b/src/main/java/com/networknt/schema/IfValidator.java index f6bacb795..1edce7bdc 100644 --- a/src/main/java/com/networknt/schema/IfValidator.java +++ b/src/main/java/com/networknt/schema/IfValidator.java @@ -71,13 +71,13 @@ public Set validate(ExecutionContext executionContext, JsonNo boolean ifConditionPassed = false; // Save flag as nested schema evaluation shouldn't trigger fail fast - boolean failFast = executionContext.getExecutionConfig().isFailFast(); + boolean failFast = executionContext.isFailFast(); try { - executionContext.getExecutionConfig().setFailFast(false); + executionContext.setFailFast(false); ifConditionPassed = this.ifSchema.validate(executionContext, node, rootNode, instanceLocation).isEmpty(); } finally { // Restore flag - executionContext.getExecutionConfig().setFailFast(failFast); + executionContext.setFailFast(failFast); } if (ifConditionPassed && this.thenSchema != null) { diff --git a/src/main/java/com/networknt/schema/ItemsValidator.java b/src/main/java/com/networknt/schema/ItemsValidator.java index 0ba438f11..a6f2e41b3 100644 --- a/src/main/java/com/networknt/schema/ItemsValidator.java +++ b/src/main/java/com/networknt/schema/ItemsValidator.java @@ -19,8 +19,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.networknt.schema.annotation.JsonNodeAnnotation; -import com.networknt.schema.walk.DefaultItemWalkListenerRunner; -import com.networknt.schema.walk.WalkListenerRunner; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,16 +36,20 @@ public class ItemsValidator extends BaseJsonValidator { private final List tupleSchema; private Boolean additionalItems; private final JsonSchema additionalSchema; - private WalkListenerRunner arrayItemWalkListenerRunner; private Boolean hasUnevaluatedItemsValidator = null; + private final JsonNodePath additionalItemsEvaluationPath; + private final SchemaLocation additionalItemsSchemaLocation; + private final JsonNode additionalItemsSchemaNode; + public ItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.ITEMS, validationContext); this.tupleSchema = new ArrayList<>(); JsonSchema foundSchema = null; JsonSchema foundAdditionalSchema = null; + JsonNode additionalItemsSchemaNode = null; if (schemaNode.isObject() || schemaNode.isBoolean()) { foundSchema = validationContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); @@ -61,6 +63,7 @@ public ItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath JsonNode addItemNode = getParentSchema().getSchemaNode().get(PROPERTY_ADDITIONAL_ITEMS); if (addItemNode != null) { + additionalItemsSchemaNode = addItemNode; if (addItemNode.isBoolean()) { this.additionalItems = addItemNode.asBoolean(); } else if (addItemNode.isObject()) { @@ -70,10 +73,11 @@ public ItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath } } } - this.arrayItemWalkListenerRunner = new DefaultItemWalkListenerRunner(validationContext.getConfig().getArrayItemWalkListeners()); - this.schema = foundSchema; this.additionalSchema = foundAdditionalSchema; + this.additionalItemsEvaluationPath = parentSchema.evaluationPath.append(PROPERTY_ADDITIONAL_ITEMS); + this.additionalItemsSchemaLocation = parentSchema.schemaLocation.append(PROPERTY_ADDITIONAL_ITEMS); + this.additionalItemsSchemaNode = additionalItemsSchemaNode; } @Override @@ -134,7 +138,8 @@ public Set validate(ExecutionContext executionContext, JsonNo if (collectAnnotations || collectAnnotations(executionContext, "additionalItems")) { executionContext.getAnnotations() .put(JsonNodeAnnotation.builder().instanceLocation(instanceLocation) - .evaluationPath(this.evaluationPath).schemaLocation(this.schemaLocation) + .evaluationPath(this.additionalItemsEvaluationPath) + .schemaLocation(this.additionalItemsSchemaLocation) .keyword("additionalItems").value(true).build()); } } @@ -176,9 +181,14 @@ private boolean doValidate(ExecutionContext executionContext, Set walk(ExecutionContext executionContext, JsonNode n if (node instanceof ArrayNode) { ArrayNode arrayNode = (ArrayNode) node; JsonNode defaultNode = null; - if (this.applyDefaultsStrategy.shouldApplyArrayDefaults() && this.schema != null) { + if (this.validationContext.getConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults() + && this.schema != null) { defaultNode = this.schema.getSchemaNode().get("default"); } int i = 0; @@ -234,13 +245,13 @@ private void doWalk(ExecutionContext executionContext, HashSet validationMessages) { - boolean executeWalk = this.arrayItemWalkListenerRunner.runPreWalkListeners(executionContext, ValidatorTypeCode.ITEMS.getValue(), + boolean executeWalk = this.validationContext.getConfig().getItemWalkListenerRunner().runPreWalkListeners(executionContext, ValidatorTypeCode.ITEMS.getValue(), node, rootNode, instanceLocation, walkSchema.getEvaluationPath(), walkSchema.getSchemaLocation(), walkSchema.getSchemaNode(), walkSchema.getParentSchema(), this.validationContext, this.validationContext.getJsonSchemaFactory()); if (executeWalk) { validationMessages.addAll(walkSchema.walk(executionContext, node, rootNode, instanceLocation, shouldValidateSchema)); } - this.arrayItemWalkListenerRunner.runPostWalkListeners(executionContext, ValidatorTypeCode.ITEMS.getValue(), node, rootNode, + this.validationContext.getConfig().getItemWalkListenerRunner().runPostWalkListeners(executionContext, ValidatorTypeCode.ITEMS.getValue(), node, rootNode, instanceLocation, this.evaluationPath, walkSchema.getSchemaLocation(), walkSchema.getSchemaNode(), walkSchema.getParentSchema(), this.validationContext, this.validationContext.getJsonSchemaFactory(), validationMessages); diff --git a/src/main/java/com/networknt/schema/ItemsValidator202012.java b/src/main/java/com/networknt/schema/ItemsValidator202012.java index 459867c83..1c955be33 100644 --- a/src/main/java/com/networknt/schema/ItemsValidator202012.java +++ b/src/main/java/com/networknt/schema/ItemsValidator202012.java @@ -19,8 +19,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.networknt.schema.annotation.JsonNodeAnnotation; -import com.networknt.schema.walk.DefaultItemWalkListenerRunner; -import com.networknt.schema.walk.WalkListenerRunner; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,13 +32,15 @@ public class ItemsValidator202012 extends BaseJsonValidator { private static final Logger logger = LoggerFactory.getLogger(ItemsValidator202012.class); private final JsonSchema schema; - private final WalkListenerRunner arrayItemWalkListenerRunner; private final int prefixCount; - + private final boolean additionalItems; + private Boolean hasUnevaluatedItemsValidator = null; - public ItemsValidator202012(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) { - super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.ITEMS_202012, validationContext); + public ItemsValidator202012(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + JsonSchema parentSchema, ValidationContext validationContext) { + super(schemaLocation, evaluationPath, schemaNode, parentSchema, ValidatorTypeCode.ITEMS_202012, + validationContext); JsonNode prefixItems = parentSchema.getSchemaNode().get("prefixItems"); if (prefixItems instanceof ArrayNode) { @@ -50,18 +50,19 @@ public ItemsValidator202012(SchemaLocation schemaLocation, JsonNodePath evaluati } else { throw new IllegalArgumentException("The value of 'prefixItems' must be an array of JSON Schema."); } - + if (schemaNode.isObject() || schemaNode.isBoolean()) { this.schema = validationContext.newSchema(schemaLocation, evaluationPath, schemaNode, parentSchema); } else { throw new IllegalArgumentException("The value of 'items' MUST be a valid JSON Schema."); } - this.arrayItemWalkListenerRunner = new DefaultItemWalkListenerRunner(validationContext.getConfig().getArrayItemWalkListeners()); + this.additionalItems = schemaNode.isBoolean() ? schemaNode.booleanValue() : true; } @Override - public Set validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { + public Set validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, + JsonNodePath instanceLocation) { debug(logger, node, rootNode, instanceLocation); // ignores non-arrays @@ -72,7 +73,17 @@ public Set validate(ExecutionContext executionContext, JsonNo for (int i = this.prefixCount; i < node.size(); ++i) { JsonNodePath path = instanceLocation.append(i); // validate with item schema (the whole array has the same item schema) - Set results = this.schema.validate(executionContext, node.get(i), rootNode, path); + Set results = null; + if (additionalItems) { + results = this.schema.validate(executionContext, node.get(i), rootNode, path); + } else { + // This handles the case where "items": false as the boolean false schema doesn't + // generate a helpful message + int x = i; + results = Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) + .locale(executionContext.getExecutionConfig().getLocale()) + .failFast(executionContext.isFailFast()).arguments(x).build()); + } if (results.isEmpty()) { // evaluatedItems.add(path); } else { @@ -96,13 +107,15 @@ public Set validate(ExecutionContext executionContext, JsonNo } @Override - public Set walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { + public Set walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, + JsonNodePath instanceLocation, boolean shouldValidateSchema) { Set validationMessages = new LinkedHashSet<>(); if (node instanceof ArrayNode) { ArrayNode arrayNode = (ArrayNode) node; JsonNode defaultNode = null; - if (this.applyDefaultsStrategy.shouldApplyArrayDefaults() && this.schema != null) { + if (this.validationContext.getConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults() + && this.schema != null) { defaultNode = this.schema.getSchemaNode().get("default"); } for (int i = this.prefixCount; i < node.size(); ++i) { @@ -112,10 +125,12 @@ public Set walk(ExecutionContext executionContext, JsonNode n n = defaultNode; } // Walk the schema. - walkSchema(executionContext, this.schema, n, rootNode, instanceLocation.append(i), shouldValidateSchema, validationMessages); + walkSchema(executionContext, this.schema, n, rootNode, instanceLocation.append(i), shouldValidateSchema, + validationMessages); } } else { - walkSchema(executionContext, this.schema, node, rootNode, instanceLocation, shouldValidateSchema, validationMessages); + walkSchema(executionContext, this.schema, node, rootNode, instanceLocation, shouldValidateSchema, + validationMessages); } return validationMessages; @@ -124,7 +139,7 @@ public Set walk(ExecutionContext executionContext, JsonNode n private void walkSchema(ExecutionContext executionContext, JsonSchema walkSchema, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema, Set validationMessages) { //@formatter:off - boolean executeWalk = this.arrayItemWalkListenerRunner.runPreWalkListeners( + boolean executeWalk = this.validationContext.getConfig().getItemWalkListenerRunner().runPreWalkListeners( executionContext, ValidatorTypeCode.ITEMS.getValue(), node, @@ -138,7 +153,7 @@ private void walkSchema(ExecutionContext executionContext, JsonSchema walkSchema if (executeWalk) { validationMessages.addAll(walkSchema.walk(executionContext, node, rootNode, instanceLocation, shouldValidateSchema)); } - this.arrayItemWalkListenerRunner.runPostWalkListeners( + this.validationContext.getConfig().getItemWalkListenerRunner().runPostWalkListeners( executionContext, ValidatorTypeCode.ITEMS.getValue(), node, @@ -162,7 +177,7 @@ public void preloadJsonSchema() { this.schema.initializeValidators(); collectAnnotations(); // cache the flag } - + private boolean collectAnnotations() { return hasUnevaluatedItemsValidator(); } diff --git a/src/main/java/com/networknt/schema/JsonSchema.java b/src/main/java/com/networknt/schema/JsonSchema.java index acada7066..466f9498d 100644 --- a/src/main/java/com/networknt/schema/JsonSchema.java +++ b/src/main/java/com/networknt/schema/JsonSchema.java @@ -22,8 +22,6 @@ import com.networknt.schema.SpecVersion.VersionFlag; import com.networknt.schema.serialization.JsonMapperFactory; import com.networknt.schema.serialization.YamlMapperFactory; -import com.networknt.schema.walk.DefaultKeywordWalkListenerRunner; -import com.networknt.schema.walk.WalkListenerRunner; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; @@ -43,15 +41,12 @@ public class JsonSchema extends BaseJsonValidator { * The validators sorted and indexed by evaluation path. */ private List validators; - private final JsonMetaSchema metaSchema; private boolean validatorsLoaded = false; private boolean recursiveAnchor = false; private JsonValidator requiredValidator = null; private TypeValidator typeValidator; - WalkListenerRunner keywordWalkListenerRunner = null; - private final String id; static JsonSchema from(ValidationContext validationContext, SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parent, boolean suppressSubSchemaRetrieval) { @@ -100,8 +95,6 @@ private JsonSchema(ValidationContext validationContext, SchemaLocation schemaLoc JsonNode schemaNode, JsonSchema parent, boolean suppressSubSchemaRetrieval) { super(resolve(schemaLocation, schemaNode, parent == null, validationContext), evaluationPath, schemaNode, parent, null, null, validationContext, suppressSubSchemaRetrieval); - this.metaSchema = this.validationContext.getMetaSchema(); - initializeConfig(); String id = this.validationContext.resolveSchemaId(this.schemaNode); if (id != null) { // In earlier drafts $id may contain an anchor fragment see draft4/idRef.json @@ -144,13 +137,6 @@ private JsonSchema(ValidationContext validationContext, SchemaLocation schemaLoc getValidators(); } - private void initializeConfig() { - if (validationContext.getConfig() != null) { - this.keywordWalkListenerRunner = new DefaultKeywordWalkListenerRunner( - this.validationContext.getConfig().getKeywordWalkListenersMap()); - } - } - /** * Copy constructor. * @@ -159,12 +145,10 @@ private void initializeConfig() { protected JsonSchema(JsonSchema copy) { super(copy); this.validators = copy.validators; - this.metaSchema = copy.metaSchema; this.validatorsLoaded = copy.validatorsLoaded; this.recursiveAnchor = copy.recursiveAnchor; this.requiredValidator = copy.requiredValidator; this.typeValidator = copy.typeValidator; - this.keywordWalkListenerRunner = copy.keywordWalkListenerRunner; this.id = copy.id; } @@ -194,7 +178,6 @@ public JsonSchema fromRef(JsonSchema refEvaluationParentSchema, JsonNodePath ref copy.requiredValidator = null; copy.typeValidator = null; copy.validators = null; - copy.initializeConfig(); return copy; } @@ -210,7 +193,6 @@ public JsonSchema withConfig(SchemaValidatorsConfig config) { copy.requiredValidator = null; copy.typeValidator = null; copy.validators = null; - copy.initializeConfig(); return copy; } return this; @@ -1041,7 +1023,7 @@ public Set walk(ExecutionContext executionContext, JsonNode n try { // Call all the pre-walk listeners. If at least one of the pre walk listeners // returns SKIP, then skip the walk. - if (this.keywordWalkListenerRunner.runPreWalkListeners(executionContext, + if (this.validationContext.getConfig().getKeywordWalkListenerRunner().runPreWalkListeners(executionContext, evaluationPathWithKeyword.getName(-1), node, rootNode, instanceLocation, v.getEvaluationPath(), v.getSchemaLocation(), this.schemaNode, this.parentSchema, this.validationContext, this.validationContext.getJsonSchemaFactory())) { @@ -1057,7 +1039,7 @@ public Set walk(ExecutionContext executionContext, JsonNode n } } finally { // Call all the post-walk listeners. - this.keywordWalkListenerRunner.runPostWalkListeners(executionContext, + this.validationContext.getConfig().getKeywordWalkListenerRunner().runPostWalkListeners(executionContext, evaluationPathWithKeyword.getName(-1), node, rootNode, instanceLocation, v.getEvaluationPath(), v.getSchemaLocation(), this.schemaNode, this.parentSchema, this.validationContext, this.validationContext.getJsonSchemaFactory(), diff --git a/src/main/java/com/networknt/schema/JsonSchemaFactory.java b/src/main/java/com/networknt/schema/JsonSchemaFactory.java index 596332c7b..4171a1002 100644 --- a/src/main/java/com/networknt/schema/JsonSchemaFactory.java +++ b/src/main/java/com/networknt/schema/JsonSchemaFactory.java @@ -257,18 +257,20 @@ protected JsonSchema newJsonSchema(final SchemaLocation schemaUri, final JsonNod final ValidationContext validationContext = createValidationContext(schemaNode, config); JsonSchema jsonSchema = doCreate(validationContext, getSchemaLocation(schemaUri), new JsonNodePath(validationContext.getConfig().getPathType()), schemaNode, null, false); - try { - /* - * Attempt to preload and resolve $refs for performance. - */ - jsonSchema.initializeValidators(); - } catch (Exception e) { - /* - * Do nothing here to allow the schema to be cached even if the remote $ref - * cannot be resolved at this time. If the developer wants to ensure that all - * remote $refs are currently resolvable they need to call initializeValidators - * themselves. - */ + if (config.isPreloadJsonSchema()) { + try { + /* + * Attempt to preload and resolve $refs for performance. + */ + jsonSchema.initializeValidators(); + } catch (Exception e) { + /* + * Do nothing here to allow the schema to be cached even if the remote $ref + * cannot be resolved at this time. If the developer wants to ensure that all + * remote $refs are currently resolvable they need to call initializeValidators + * themselves. + */ + } } return jsonSchema; } @@ -587,7 +589,7 @@ public JsonSchema getSchema(final SchemaLocation schemaUri, final JsonNode jsonN * @return the schema */ public JsonSchema getSchema(final SchemaLocation schemaUri, final JsonNode jsonNode) { - return newJsonSchema(schemaUri, jsonNode, null); + return newJsonSchema(schemaUri, jsonNode, createSchemaValidatorsConfig()); } /** @@ -620,7 +622,7 @@ public JsonSchema getSchema(final JsonNode jsonNode, final SchemaValidatorsConfi * @return the schema */ public JsonSchema getSchema(final JsonNode jsonNode) { - return newJsonSchema(null, jsonNode, null); + return newJsonSchema(null, jsonNode, createSchemaValidatorsConfig()); } private boolean isYaml(final SchemaLocation schemaUri) { diff --git a/src/main/java/com/networknt/schema/MaxItemsValidator.java b/src/main/java/com/networknt/schema/MaxItemsValidator.java index a232349cf..51e4be62d 100644 --- a/src/main/java/com/networknt/schema/MaxItemsValidator.java +++ b/src/main/java/com/networknt/schema/MaxItemsValidator.java @@ -46,13 +46,13 @@ public Set validate(ExecutionContext executionContext, JsonNo if (node.size() > max) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(max).build()); + .failFast(executionContext.isFailFast()).arguments(max).build()); } } else if (this.validationContext.getConfig().isTypeLoose()) { if (1 > max) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(max).build()); + .failFast(executionContext.isFailFast()).arguments(max).build()); } } diff --git a/src/main/java/com/networknt/schema/MaxLengthValidator.java b/src/main/java/com/networknt/schema/MaxLengthValidator.java index 07e7b79d0..08882ed53 100644 --- a/src/main/java/com/networknt/schema/MaxLengthValidator.java +++ b/src/main/java/com/networknt/schema/MaxLengthValidator.java @@ -50,7 +50,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (node.textValue().codePointCount(0, node.textValue().length()) > maxLength) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(maxLength).build()); + .failFast(executionContext.isFailFast()).arguments(maxLength).build()); } return Collections.emptySet(); } diff --git a/src/main/java/com/networknt/schema/MaxPropertiesValidator.java b/src/main/java/com/networknt/schema/MaxPropertiesValidator.java index b50b6c57d..f23f303e6 100644 --- a/src/main/java/com/networknt/schema/MaxPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/MaxPropertiesValidator.java @@ -46,7 +46,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (node.size() > max) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(max).build()); + .failFast(executionContext.isFailFast()).arguments(max).build()); } } diff --git a/src/main/java/com/networknt/schema/MaximumValidator.java b/src/main/java/com/networknt/schema/MaximumValidator.java index 0137f3b36..03a7c9cf6 100644 --- a/src/main/java/com/networknt/schema/MaximumValidator.java +++ b/src/main/java/com/networknt/schema/MaximumValidator.java @@ -118,7 +118,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (typedMaximum.crossesThreshold(node)) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()) + .failFast(executionContext.isFailFast()) .arguments(typedMaximum.thresholdValue()).build()); } return Collections.emptySet(); diff --git a/src/main/java/com/networknt/schema/MinItemsValidator.java b/src/main/java/com/networknt/schema/MinItemsValidator.java index 85e833db8..83db6ec17 100644 --- a/src/main/java/com/networknt/schema/MinItemsValidator.java +++ b/src/main/java/com/networknt/schema/MinItemsValidator.java @@ -45,14 +45,14 @@ public Set validate(ExecutionContext executionContext, JsonNo if (node.size() < min) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(min, node.size()) + .failFast(executionContext.isFailFast()).arguments(min, node.size()) .build()); } } else if (this.validationContext.getConfig().isTypeLoose()) { if (1 < min) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(min, 1).build()); + .failFast(executionContext.isFailFast()).arguments(min, 1).build()); } } diff --git a/src/main/java/com/networknt/schema/MinLengthValidator.java b/src/main/java/com/networknt/schema/MinLengthValidator.java index c5dc0435a..c82b8ecf4 100644 --- a/src/main/java/com/networknt/schema/MinLengthValidator.java +++ b/src/main/java/com/networknt/schema/MinLengthValidator.java @@ -51,7 +51,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (node.textValue().codePointCount(0, node.textValue().length()) < minLength) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(minLength).build()); + .failFast(executionContext.isFailFast()).arguments(minLength).build()); } return Collections.emptySet(); } diff --git a/src/main/java/com/networknt/schema/MinMaxContainsValidator.java b/src/main/java/com/networknt/schema/MinMaxContainsValidator.java index 46db1447e..768aba654 100644 --- a/src/main/java/com/networknt/schema/MinMaxContainsValidator.java +++ b/src/main/java/com/networknt/schema/MinMaxContainsValidator.java @@ -63,9 +63,10 @@ public Set validate(ExecutionContext executionContext, JsonNo JsonNodePath instanceLocation) { return this.analysis != null ? this.analysis.stream() .map(analysis -> message().instanceNode(node) - .instanceLocation(analysis.getSchemaLocation().getFragment()) + .instanceLocation(instanceLocation) .messageKey(analysis.getMessageKey()).locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()) + .failFast(executionContext.isFailFast()) + .type(analysis.getMessageKey()) .arguments(parentSchema.getSchemaNode().toString()).build()) .collect(Collectors.toCollection(LinkedHashSet::new)) : Collections.emptySet(); } diff --git a/src/main/java/com/networknt/schema/MinPropertiesValidator.java b/src/main/java/com/networknt/schema/MinPropertiesValidator.java index 17b4fbe3c..26d6de145 100644 --- a/src/main/java/com/networknt/schema/MinPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/MinPropertiesValidator.java @@ -46,7 +46,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (node.size() < min) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(min).build()); + .failFast(executionContext.isFailFast()).arguments(min).build()); } } diff --git a/src/main/java/com/networknt/schema/MinimumValidator.java b/src/main/java/com/networknt/schema/MinimumValidator.java index 3e43624d5..8b2e5e709 100644 --- a/src/main/java/com/networknt/schema/MinimumValidator.java +++ b/src/main/java/com/networknt/schema/MinimumValidator.java @@ -125,7 +125,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (typedMinimum.crossesThreshold(node)) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()) + .failFast(executionContext.isFailFast()) .arguments(typedMinimum.thresholdValue()).build()); } return Collections.emptySet(); diff --git a/src/main/java/com/networknt/schema/MultipleOfValidator.java b/src/main/java/com/networknt/schema/MultipleOfValidator.java index 65320b0d3..95b57ce85 100644 --- a/src/main/java/com/networknt/schema/MultipleOfValidator.java +++ b/src/main/java/com/networknt/schema/MultipleOfValidator.java @@ -49,7 +49,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (dividend.divideAndRemainder(this.divisor)[1].abs().compareTo(BigDecimal.ZERO) > 0) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(this.divisor) + .failFast(executionContext.isFailFast()).arguments(this.divisor) .build()); } } diff --git a/src/main/java/com/networknt/schema/NonValidationKeyword.java b/src/main/java/com/networknt/schema/NonValidationKeyword.java index c5af300b1..df5d9d1e9 100644 --- a/src/main/java/com/networknt/schema/NonValidationKeyword.java +++ b/src/main/java/com/networknt/schema/NonValidationKeyword.java @@ -46,8 +46,10 @@ public Validator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, Jso if ("$defs".equals(keyword.getValue()) || "definitions".equals(keyword.getValue())) { for (Iterator> field = schemaNode.fields(); field.hasNext(); ) { Entry property = field.next(); - validationContext.newSchema(schemaLocation.append(property.getKey()), - evaluationPath.append(property.getKey()), property.getValue(), parentSchema); + SchemaLocation location = schemaLocation.append(property.getKey()); + JsonSchema schema = validationContext.newSchema(location, evaluationPath.append(property.getKey()), + property.getValue(), parentSchema); + validationContext.getSchemaReferences().put(location.toString(), schema); } } } diff --git a/src/main/java/com/networknt/schema/NotAllowedValidator.java b/src/main/java/com/networknt/schema/NotAllowedValidator.java index baf8dd762..b21ca3e60 100644 --- a/src/main/java/com/networknt/schema/NotAllowedValidator.java +++ b/src/main/java/com/networknt/schema/NotAllowedValidator.java @@ -55,7 +55,7 @@ public Set validate(ExecutionContext executionContext, JsonNo errors.add(message().property(fieldName).instanceNode(node) .instanceLocation(instanceLocation.append(fieldName)) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(fieldName).build()); + .failFast(executionContext.isFailFast()).arguments(fieldName).build()); } } diff --git a/src/main/java/com/networknt/schema/NotValidator.java b/src/main/java/com/networknt/schema/NotValidator.java index 9a2c2e36e..a2d7f8aca 100644 --- a/src/main/java/com/networknt/schema/NotValidator.java +++ b/src/main/java/com/networknt/schema/NotValidator.java @@ -42,18 +42,18 @@ public Set validate(ExecutionContext executionContext, JsonNo debug(logger, node, rootNode, instanceLocation); // Save flag as nested schema evaluation shouldn't trigger fail fast - boolean failFast = executionContext.getExecutionConfig().isFailFast(); + boolean failFast = executionContext.isFailFast(); try { - executionContext.getExecutionConfig().setFailFast(false); + executionContext.setFailFast(false); errors = this.schema.validate(executionContext, node, rootNode, instanceLocation); } finally { // Restore flag - executionContext.getExecutionConfig().setFailFast(failFast); + executionContext.setFailFast(failFast); } if (errors.isEmpty()) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(this.schema.toString()) + .failFast(executionContext.isFailFast()).arguments(this.schema.toString()) .build()); } return Collections.emptySet(); @@ -69,7 +69,7 @@ public Set walk(ExecutionContext executionContext, JsonNode n if (errors.isEmpty()) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(this.schema.toString()) + .failFast(executionContext.isFailFast()).arguments(this.schema.toString()) .build()); } return Collections.emptySet(); diff --git a/src/main/java/com/networknt/schema/OneOfValidator.java b/src/main/java/com/networknt/schema/OneOfValidator.java index 1fe74a56e..34a38afb7 100644 --- a/src/main/java/com/networknt/schema/OneOfValidator.java +++ b/src/main/java/com/networknt/schema/OneOfValidator.java @@ -57,9 +57,9 @@ public Set validate(ExecutionContext executionContext, JsonNo Set childErrors = new LinkedHashSet<>(); // Save flag as nested schema evaluation shouldn't trigger fail fast - boolean failFast = executionContext.getExecutionConfig().isFailFast(); + boolean failFast = executionContext.isFailFast(); try { - executionContext.getExecutionConfig().setFailFast(false); + executionContext.setFailFast(false); for (JsonSchema schema : this.schemas) { Set schemaErrors = Collections.emptySet(); @@ -88,11 +88,13 @@ public Set validate(ExecutionContext executionContext, JsonNo break; } - childErrors.addAll(schemaErrors); + if (reportChildErrors(executionContext)) { + childErrors.addAll(schemaErrors); + } } } finally { // Restore flag - executionContext.getExecutionConfig().setFailFast(failFast); + executionContext.setFailFast(failFast); } // ensure there is always an "OneOf" error reported if number of valid schemas @@ -100,7 +102,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (numberOfValidSchema != 1) { ValidationMessage message = message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()) + .failFast(executionContext.isFailFast()) .arguments(Integer.toString(numberOfValidSchema)).build(); errors.add(message); errors.addAll(childErrors); @@ -116,6 +118,18 @@ public Set validate(ExecutionContext executionContext, JsonNo return Collections.unmodifiableSet(errors); } + + /** + * Determines if child errors should be reported. + * + * @param executionContext the execution context + * @return true if child errors should be reported + */ + protected boolean reportChildErrors(ExecutionContext executionContext) { + // check the original flag if it's going to fail fast anyway + // no point aggregating all the errors + return !executionContext.getExecutionConfig().isFailFast(); + } protected boolean canShortCircuit() { if (this.canShortCircuit == null) { diff --git a/src/main/java/com/networknt/schema/PatternValidator.java b/src/main/java/com/networknt/schema/PatternValidator.java index 9b7f087a8..db6f32e4b 100644 --- a/src/main/java/com/networknt/schema/PatternValidator.java +++ b/src/main/java/com/networknt/schema/PatternValidator.java @@ -60,7 +60,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (!matches(node.asText())) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(this.pattern).build()); + .failFast(executionContext.isFailFast()).arguments(this.pattern).build()); } } catch (JsonSchemaException e) { throw e; diff --git a/src/main/java/com/networknt/schema/PrefixItemsValidator.java b/src/main/java/com/networknt/schema/PrefixItemsValidator.java index 230f67798..029088121 100644 --- a/src/main/java/com/networknt/schema/PrefixItemsValidator.java +++ b/src/main/java/com/networknt/schema/PrefixItemsValidator.java @@ -19,8 +19,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.networknt.schema.annotation.JsonNodeAnnotation; -import com.networknt.schema.walk.DefaultItemWalkListenerRunner; -import com.networknt.schema.walk.WalkListenerRunner; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,7 +35,6 @@ public class PrefixItemsValidator extends BaseJsonValidator { private static final Logger logger = LoggerFactory.getLogger(PrefixItemsValidator.class); private final List tupleSchema; - private WalkListenerRunner arrayItemWalkListenerRunner; private Boolean hasUnevaluatedItemsValidator = null; @@ -53,8 +50,6 @@ public PrefixItemsValidator(SchemaLocation schemaLocation, JsonNodePath evaluati } else { throw new IllegalArgumentException("The value of 'prefixItems' MUST be a non-empty array of valid JSON Schemas."); } - - this.arrayItemWalkListenerRunner = new DefaultItemWalkListenerRunner(validationContext.getConfig().getArrayItemWalkListeners()); } @Override @@ -101,7 +96,8 @@ public Set validate(ExecutionContext executionContext, JsonNo public Set walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { Set validationMessages = new LinkedHashSet<>(); - if (this.applyDefaultsStrategy.shouldApplyArrayDefaults() && node.isArray()) { + if (this.validationContext.getConfig().getApplyDefaultsStrategy().shouldApplyArrayDefaults() + && node.isArray()) { ArrayNode array = (ArrayNode) node; int count = Math.min(node.size(), this.tupleSchema.size()); for (int i = 0; i < count; ++i) { @@ -127,7 +123,7 @@ private void doWalk(ExecutionContext executionContext, Set va private void walkSchema(ExecutionContext executionContext, JsonSchema walkSchema, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema, Set validationMessages) { //@formatter:off - boolean executeWalk = this.arrayItemWalkListenerRunner.runPreWalkListeners( + boolean executeWalk = this.validationContext.getConfig().getItemWalkListenerRunner().runPreWalkListeners( executionContext, ValidatorTypeCode.PREFIX_ITEMS.getValue(), node, @@ -141,7 +137,7 @@ private void walkSchema(ExecutionContext executionContext, JsonSchema walkSchema if (executeWalk) { validationMessages.addAll(walkSchema.walk(executionContext, node, rootNode, instanceLocation, shouldValidateSchema)); } - this.arrayItemWalkListenerRunner.runPostWalkListeners( + this.validationContext.getConfig().getItemWalkListenerRunner().runPostWalkListeners( executionContext, ValidatorTypeCode.PREFIX_ITEMS.getValue(), node, diff --git a/src/main/java/com/networknt/schema/PropertiesValidator.java b/src/main/java/com/networknt/schema/PropertiesValidator.java index f3ce77719..bc526a32f 100644 --- a/src/main/java/com/networknt/schema/PropertiesValidator.java +++ b/src/main/java/com/networknt/schema/PropertiesValidator.java @@ -20,7 +20,6 @@ import com.fasterxml.jackson.databind.node.JsonNodeType; import com.fasterxml.jackson.databind.node.ObjectNode; import com.networknt.schema.annotation.JsonNodeAnnotation; -import com.networknt.schema.walk.DefaultPropertyWalkListenerRunner; import com.networknt.schema.walk.WalkListenerRunner; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,8 +49,6 @@ public PropertiesValidator(SchemaLocation schemaLocation, JsonNodePath evaluatio public Set validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { debug(logger, node, rootNode, instanceLocation); - WalkListenerRunner propertyWalkListenerRunner = new DefaultPropertyWalkListenerRunner(this.validationContext.getConfig().getPropertyWalkListeners()); - Set errors = null; // get the Validator state object storing validation data @@ -94,7 +91,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (errors == null) { errors = new LinkedHashSet<>(); } - walkSchema(executionContext, entry, node, rootNode, instanceLocation, state.isValidationEnabled(), errors, propertyWalkListenerRunner); + walkSchema(executionContext, entry, node, rootNode, instanceLocation, state.isValidationEnabled(), errors, this.validationContext.getConfig().getPropertyWalkListenerRunner()); } // reset the complex flag to the original value before the recursive call @@ -143,13 +140,14 @@ public Set validate(ExecutionContext executionContext, JsonNo @Override public Set walk(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation, boolean shouldValidateSchema) { HashSet validationMessages = new LinkedHashSet<>(); - if (this.applyDefaultsStrategy.shouldApplyPropertyDefaults() && null != node && node.getNodeType() == JsonNodeType.OBJECT) { + if (this.validationContext.getConfig().getApplyDefaultsStrategy().shouldApplyPropertyDefaults() && null != node + && node.getNodeType() == JsonNodeType.OBJECT) { applyPropertyDefaults((ObjectNode) node); } if (shouldValidateSchema) { validationMessages.addAll(validate(executionContext, node, rootNode, instanceLocation)); } else { - WalkListenerRunner propertyWalkListenerRunner = new DefaultPropertyWalkListenerRunner(this.validationContext.getConfig().getPropertyWalkListeners()); + WalkListenerRunner propertyWalkListenerRunner = this.validationContext.getConfig().getPropertyWalkListenerRunner(); for (Map.Entry entry : this.schemas.entrySet()) { walkSchema(executionContext, entry, node, rootNode, instanceLocation, shouldValidateSchema, validationMessages, propertyWalkListenerRunner); } @@ -176,8 +174,8 @@ private void applyPropertyDefaults(ObjectNode node) { if (defaultNode == null) { continue; } - boolean applyDefault = propertyNode == null - || (propertyNode.isNull() && this.applyDefaultsStrategy.shouldApplyPropertyDefaultsIfNull()); + boolean applyDefault = propertyNode == null || (propertyNode.isNull() && this.validationContext.getConfig() + .getApplyDefaultsStrategy().shouldApplyPropertyDefaultsIfNull()); if (applyDefault) { node.set(entry.getKey(), defaultNode); } diff --git a/src/main/java/com/networknt/schema/PropertyNamesValidator.java b/src/main/java/com/networknt/schema/PropertyNamesValidator.java index 12465d34b..c2935eaec 100644 --- a/src/main/java/com/networknt/schema/PropertyNamesValidator.java +++ b/src/main/java/com/networknt/schema/PropertyNamesValidator.java @@ -49,9 +49,9 @@ public Set validate(ExecutionContext executionContext, JsonNo msg = msg.substring(path.length()).replaceFirst("^:\\s*", ""); errors.add( - message().property(pname).instanceNode(node).instanceLocation(schemaError.getInstanceLocation()) + message().property(pname).instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(msg).build()); + .failFast(executionContext.isFailFast()).arguments(pname, msg).build()); } } return Collections.unmodifiableSet(errors); diff --git a/src/main/java/com/networknt/schema/ReadOnlyValidator.java b/src/main/java/com/networknt/schema/ReadOnlyValidator.java index bf2759bfe..9ea33eaaa 100644 --- a/src/main/java/com/networknt/schema/ReadOnlyValidator.java +++ b/src/main/java/com/networknt/schema/ReadOnlyValidator.java @@ -45,7 +45,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (this.readOnly) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).build()); + .failFast(executionContext.isFailFast()).build()); } return Collections.emptySet(); } diff --git a/src/main/java/com/networknt/schema/RequiredValidator.java b/src/main/java/com/networknt/schema/RequiredValidator.java index 131bd42fe..e9a19cc14 100644 --- a/src/main/java/com/networknt/schema/RequiredValidator.java +++ b/src/main/java/com/networknt/schema/RequiredValidator.java @@ -62,7 +62,7 @@ public Set validate(ExecutionContext executionContext, JsonNo */ errors.add(message().instanceNode(node).property(fieldName).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(fieldName).build()); + .failFast(executionContext.isFailFast()).arguments(fieldName).build()); } } diff --git a/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java b/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java index 78084a81d..a85f75b60 100644 --- a/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java +++ b/src/main/java/com/networknt/schema/SchemaValidatorsConfig.java @@ -19,7 +19,11 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.i18n.DefaultMessageSource; import com.networknt.schema.i18n.MessageSource; +import com.networknt.schema.walk.DefaultItemWalkListenerRunner; +import com.networknt.schema.walk.DefaultKeywordWalkListenerRunner; +import com.networknt.schema.walk.DefaultPropertyWalkListenerRunner; import com.networknt.schema.walk.JsonSchemaWalkListener; +import com.networknt.schema.walk.WalkListenerRunner; import java.util.ArrayList; import java.util.HashMap; @@ -50,7 +54,7 @@ public class SchemaValidatorsConfig { * When set to true, walker sets nodes that are missing or NullNode to the * default value, if any, and mutate the input json. */ - private ApplyDefaultsStrategy applyDefaultsStrategy; + private ApplyDefaultsStrategy applyDefaultsStrategy = ApplyDefaultsStrategy.EMPTY_APPLY_DEFAULTS_STRATEGY; /** * When set to true, use ECMA-262 compatible validator @@ -117,6 +121,11 @@ public class SchemaValidatorsConfig { */ private PathType pathType = PathType.DEFAULT; + /** + * Controls if the schema will automatically be preloaded. + */ + private boolean preloadJsonSchema = true; + // This is just a constant for listening to all Keywords. public static final String ALL_KEYWORD_WALK_LISTENER_KEY = "com.networknt.AllKeywordWalkListener"; @@ -231,7 +240,8 @@ public boolean isFailFast() { } public void setApplyDefaultsStrategy(ApplyDefaultsStrategy applyDefaultsStrategy) { - this.applyDefaultsStrategy = applyDefaultsStrategy; + this.applyDefaultsStrategy = applyDefaultsStrategy != null ? applyDefaultsStrategy + : ApplyDefaultsStrategy.EMPTY_APPLY_DEFAULTS_STRATEGY; } public ApplyDefaultsStrategy getApplyDefaultsStrategy() { @@ -330,6 +340,24 @@ public List getArrayItemWalkListeners() { return this.itemWalkListeners; } + private final WalkListenerRunner itemWalkListenerRunner = new DefaultItemWalkListenerRunner(getArrayItemWalkListeners()); + + WalkListenerRunner getItemWalkListenerRunner() { + return this.itemWalkListenerRunner; + } + + private WalkListenerRunner keywordWalkListenerRunner = new DefaultKeywordWalkListenerRunner(getKeywordWalkListenersMap()); + + WalkListenerRunner getKeywordWalkListenerRunner() { + return this.keywordWalkListenerRunner; + } + + private WalkListenerRunner propertyWalkListenerRunner = new DefaultPropertyWalkListenerRunner(getPropertyWalkListeners()); + + WalkListenerRunner getPropertyWalkListenerRunner() { + return this.propertyWalkListenerRunner; + } + public SchemaValidatorsConfig() { } @@ -566,4 +594,22 @@ public JsonSchemaIdValidator getSchemaIdValidator() { public void setSchemaIdValidator(JsonSchemaIdValidator schemaIdValidator) { this.schemaIdValidator = schemaIdValidator; } + + /** + * Gets if the schema should be preloaded. + * + * @return true if it should be preloaded + */ + public boolean isPreloadJsonSchema() { + return preloadJsonSchema; + } + + /** + * Sets if the schema should be preloaded. + * + * @param preloadJsonSchema true to preload + */ + public void setPreloadJsonSchema(boolean preloadJsonSchema) { + this.preloadJsonSchema = preloadJsonSchema; + } } diff --git a/src/main/java/com/networknt/schema/TypeValidator.java b/src/main/java/com/networknt/schema/TypeValidator.java index fb151c9cb..7f7736ec5 100644 --- a/src/main/java/com/networknt/schema/TypeValidator.java +++ b/src/main/java/com/networknt/schema/TypeValidator.java @@ -62,7 +62,7 @@ public Set validate(ExecutionContext executionContext, JsonNo JsonType nodeType = TypeFactory.getValueNodeType(node, this.validationContext.getConfig()); return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()) + .failFast(executionContext.isFailFast()) .arguments(nodeType.toString(), this.schemaType.toString()).build()); } return Collections.emptySet(); diff --git a/src/main/java/com/networknt/schema/UnevaluatedItemsValidator.java b/src/main/java/com/networknt/schema/UnevaluatedItemsValidator.java index 784ecaa90..94a63bc44 100644 --- a/src/main/java/com/networknt/schema/UnevaluatedItemsValidator.java +++ b/src/main/java/com/networknt/schema/UnevaluatedItemsValidator.java @@ -190,7 +190,7 @@ public Set validate(ExecutionContext executionContext, JsonNo .map(m -> message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) .arguments(m.getInstanceLocation().getName(-1)) - .failFast(executionContext.getExecutionConfig().isFailFast()).build()) + .failFast(executionContext.isFailFast()).build()) .collect(Collectors.toCollection(LinkedHashSet::new)); } } diff --git a/src/main/java/com/networknt/schema/UnevaluatedPropertiesValidator.java b/src/main/java/com/networknt/schema/UnevaluatedPropertiesValidator.java index c32597854..34d5830f9 100644 --- a/src/main/java/com/networknt/schema/UnevaluatedPropertiesValidator.java +++ b/src/main/java/com/networknt/schema/UnevaluatedPropertiesValidator.java @@ -109,20 +109,27 @@ public Set validate(ExecutionContext executionContext, JsonNo } Set messages = new LinkedHashSet<>(); - for (Iterator it = node.fieldNames(); it.hasNext();) { - String fieldName = it.next(); - if (!existingEvaluatedProperties.contains(fieldName)) { - evaluatedProperties.add(fieldName); - if (this.schemaNode.isBoolean() && this.schemaNode.booleanValue() == false) { - // All fails as "unevaluatedProperties: false" - messages.add(message().instanceNode(node).instanceLocation(instanceLocation.append(fieldName)) - .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).build()); - } else { - messages.addAll(this.schema.validate(executionContext, node.get(fieldName), node, - instanceLocation.append(fieldName))); + // Save flag as nested schema evaluation shouldn't trigger fail fast + boolean failFast = executionContext.isFailFast(); + try { + executionContext.setFailFast(false); + for (Iterator it = node.fieldNames(); it.hasNext();) { + String fieldName = it.next(); + if (!existingEvaluatedProperties.contains(fieldName)) { + evaluatedProperties.add(fieldName); + if (this.schemaNode.isBoolean() && this.schemaNode.booleanValue() == false) { + // All fails as "unevaluatedProperties: false" + messages.add(message().instanceNode(node).instanceLocation(instanceLocation.append(fieldName)) + .locale(executionContext.getExecutionConfig().getLocale()) + .failFast(executionContext.isFailFast()).build()); + } else { + messages.addAll(this.schema.validate(executionContext, node.get(fieldName), node, + instanceLocation.append(fieldName))); + } } } + } finally { + executionContext.setFailFast(failFast); // restore flag } if (!messages.isEmpty()) { // Report these as unevaluated paths or not matching the unevaluatedProperties @@ -132,7 +139,7 @@ public Set validate(ExecutionContext executionContext, JsonNo .locale(executionContext.getExecutionConfig().getLocale()) .arguments(m.getInstanceLocation().getName(-1)) .property(m.getInstanceLocation().getName(-1)) - .failFast(executionContext.getExecutionConfig().isFailFast()).build()) + .failFast(executionContext.isFailFast()).build()) .collect(Collectors.toCollection(LinkedHashSet::new)); } executionContext.getAnnotations() diff --git a/src/main/java/com/networknt/schema/UnionTypeValidator.java b/src/main/java/com/networknt/schema/UnionTypeValidator.java index c04626a08..2b86ef1c4 100644 --- a/src/main/java/com/networknt/schema/UnionTypeValidator.java +++ b/src/main/java/com/networknt/schema/UnionTypeValidator.java @@ -73,9 +73,9 @@ public Set validate(ExecutionContext executionContext, JsonNo boolean valid = false; // Save flag as nested schema evaluation shouldn't trigger fail fast - boolean failFast = executionContext.getExecutionConfig().isFailFast(); + boolean failFast = executionContext.isFailFast(); try { - executionContext.getExecutionConfig().setFailFast(false); + executionContext.setFailFast(false); for (JsonValidator schema : schemas) { Set errors = schema.validate(executionContext, node, rootNode, instanceLocation); if (errors == null || errors.isEmpty()) { @@ -85,14 +85,14 @@ public Set validate(ExecutionContext executionContext, JsonNo } } finally { // Restore flag - executionContext.getExecutionConfig().setFailFast(failFast); + executionContext.setFailFast(failFast); } if (!valid) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .type("type") .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).arguments(nodeType.toString(), error) + .failFast(executionContext.isFailFast()).arguments(nodeType.toString(), error) .build()); } diff --git a/src/main/java/com/networknt/schema/UniqueItemsValidator.java b/src/main/java/com/networknt/schema/UniqueItemsValidator.java index dd8c5c6e0..be43b965b 100644 --- a/src/main/java/com/networknt/schema/UniqueItemsValidator.java +++ b/src/main/java/com/networknt/schema/UniqueItemsValidator.java @@ -48,7 +48,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (!set.add(n)) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).build()); + .failFast(executionContext.isFailFast()).build()); } } } diff --git a/src/main/java/com/networknt/schema/WriteOnlyValidator.java b/src/main/java/com/networknt/schema/WriteOnlyValidator.java index ed2ce4ae9..e13da5a04 100644 --- a/src/main/java/com/networknt/schema/WriteOnlyValidator.java +++ b/src/main/java/com/networknt/schema/WriteOnlyValidator.java @@ -29,7 +29,7 @@ public Set validate(ExecutionContext executionContext, JsonNo if (this.writeOnly) { return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()).build()); + .failFast(executionContext.isFailFast()).build()); } return Collections.emptySet(); } diff --git a/src/main/java/com/networknt/schema/format/DateTimeValidator.java b/src/main/java/com/networknt/schema/format/DateTimeValidator.java index 164f0efb9..54900fca0 100644 --- a/src/main/java/com/networknt/schema/format/DateTimeValidator.java +++ b/src/main/java/com/networknt/schema/format/DateTimeValidator.java @@ -67,7 +67,7 @@ public Set validate(ExecutionContext executionContext, JsonNo return Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation) .type("format") .locale(executionContext.getExecutionConfig().getLocale()) - .failFast(executionContext.getExecutionConfig().isFailFast()) + .failFast(executionContext.isFailFast()) .arguments(node.textValue(), DATETIME).build()); } } diff --git a/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java b/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java index d69c62013..a557b325e 100644 --- a/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java +++ b/src/main/java/com/networknt/schema/output/HierarchicalOutputUnitFormatter.java @@ -52,14 +52,20 @@ public static OutputUnit format(JsonSchema jsonSchema, Set va Map> droppedAnnotations = data.getDroppedAnnotations(); // Evaluation path to output unit - Map index = new LinkedHashMap<>(); - index.put(new JsonNodePath(validationContext.getConfig().getPathType()), root); + Map> index = new LinkedHashMap<>(); + Map r = new LinkedHashMap<>(); + r.put(new JsonNodePath(validationContext.getConfig().getPathType()), root); + index.put(new JsonNodePath(validationContext.getConfig().getPathType()), r); // Get all the evaluation paths with data - Set keys = new LinkedHashSet<>(); - errors.keySet().stream().forEach(k -> keys.add(k.getEvaluationPath())); - annotations.keySet().stream().forEach(k -> keys.add(k.getEvaluationPath())); - droppedAnnotations.keySet().stream().forEach(k -> keys.add(k.getEvaluationPath())); + // This is a map of evaluation path to instance location + Map> keys = new LinkedHashMap<>(); + errors.keySet().stream().forEach(k -> keys.computeIfAbsent(k.getEvaluationPath(), a -> new LinkedHashSet<>()) + .add(k.getInstanceLocation())); + annotations.keySet().stream().forEach(k -> keys + .computeIfAbsent(k.getEvaluationPath(), a -> new LinkedHashSet<>()).add(k.getInstanceLocation())); + droppedAnnotations.keySet().stream().forEach(k -> keys + .computeIfAbsent(k.getEvaluationPath(), a -> new LinkedHashSet<>()).add(k.getInstanceLocation())); errors.keySet().stream().forEach(k -> buildIndex(k, index, keys, root)); annotations.keySet().stream().forEach(k -> buildIndex(k, index, keys, root)); @@ -68,7 +74,7 @@ public static OutputUnit format(JsonSchema jsonSchema, Set va // Process all the data for (Entry> error : errors.entrySet()) { OutputUnitKey key = error.getKey(); - OutputUnit unit = index.get(key.getEvaluationPath()); + OutputUnit unit = index.get(key.getEvaluationPath()).get(key.getInstanceLocation()); unit.setInstanceLocation(key.getInstanceLocation().toString()); unit.setSchemaLocation(key.getSchemaLocation().toString()); unit.setValid(false); @@ -77,7 +83,7 @@ public static OutputUnit format(JsonSchema jsonSchema, Set va for (Entry> annotation : annotations.entrySet()) { OutputUnitKey key = annotation.getKey(); - OutputUnit unit = index.get(key.getEvaluationPath()); + OutputUnit unit = index.get(key.getEvaluationPath()).get(key.getInstanceLocation()); String instanceLocation = key.getInstanceLocation().toString(); String schemaLocation = key.getSchemaLocation().toString(); if (unit.getInstanceLocation() != null && !unit.getInstanceLocation().equals(instanceLocation)) { @@ -94,7 +100,7 @@ public static OutputUnit format(JsonSchema jsonSchema, Set va for (Entry> droppedAnnotation : droppedAnnotations.entrySet()) { OutputUnitKey key = droppedAnnotation.getKey(); - OutputUnit unit = index.get(key.getEvaluationPath()); + OutputUnit unit = index.get(key.getEvaluationPath()).get(key.getInstanceLocation()); String instanceLocation = key.getInstanceLocation().toString(); String schemaLocation = key.getSchemaLocation().toString(); if (unit.getInstanceLocation() != null && !unit.getInstanceLocation().equals(instanceLocation)) { @@ -117,11 +123,11 @@ public static OutputUnit format(JsonSchema jsonSchema, Set va * * @param key the current key to process * @param index contains all the mappings from evaluation path to output units - * @param keys that contain all the evaluation paths with data + * @param keys that contain all the evaluation paths with instance data * @param root the root output unit */ - protected static void buildIndex(OutputUnitKey key, Map index, Set keys, - OutputUnit root) { + protected static void buildIndex(OutputUnitKey key, Map> index, + Map> keys, OutputUnit root) { if (index.containsKey(key.getEvaluationPath())) { return; } @@ -136,23 +142,32 @@ protected static void buildIndex(OutputUnitKey key, Map()); + for (JsonNodePath instanceLocation : keys.get(current)) { + OutputUnit child = new OutputUnit(); + child.setValid(true); + child.setEvaluationPath(current.toString()); + child.setInstanceLocation(instanceLocation.toString()); + index.computeIfAbsent(current, n -> new LinkedHashMap<>()).put(instanceLocation, child); + if (parent.getDetails() == null) { + parent.setDetails(new ArrayList<>()); + } + parent.getDetails().add(child); } - parent.getDetails().add(child); } // If exists in the index this is the new parent // Otherwise this is an evaluation path with no data and hence should be skipped - OutputUnit child = index.get(current); - if (child != null) { - parent = child; + // InstanceLocation to OutputUnit + Map result = index.get(current); + if (result != null) { + for (Entry entry : result.entrySet()) { + if (key.getInstanceLocation().startsWith(entry.getKey())) { + parent = entry.getValue(); + break; + } + } } } } diff --git a/src/main/java/com/networknt/schema/output/OutputUnitKey.java b/src/main/java/com/networknt/schema/output/OutputUnitKey.java index 5c99151af..760f75871 100644 --- a/src/main/java/com/networknt/schema/output/OutputUnitKey.java +++ b/src/main/java/com/networknt/schema/output/OutputUnitKey.java @@ -17,15 +17,22 @@ import java.util.Objects; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.networknt.schema.JsonNodePath; import com.networknt.schema.SchemaLocation; +import com.networknt.schema.serialization.JsonMapperFactory; /** * Output Unit Key. */ public class OutputUnitKey { + @JsonSerialize(using = ToStringSerializer.class) final JsonNodePath evaluationPath; + @JsonSerialize(using = ToStringSerializer.class) final SchemaLocation schemaLocation; + @JsonSerialize(using = ToStringSerializer.class) final JsonNodePath instanceLocation; public OutputUnitKey(JsonNodePath evaluationPath, SchemaLocation schemaLocation, JsonNodePath instanceLocation) { @@ -65,4 +72,16 @@ public boolean equals(Object obj) { && Objects.equals(instanceLocation, other.instanceLocation) && Objects.equals(schemaLocation, other.schemaLocation); } + + @Override + public String toString() { + try { + return JsonMapperFactory.getInstance().writerWithDefaultPrettyPrinter().writeValueAsString(this); + } catch (JsonProcessingException e) { + return "OutputUnitKey [evaluationPath=" + evaluationPath + ", schemaLocation=" + schemaLocation + + ", instanceLocation=" + instanceLocation + "]"; + } + } + + } \ No newline at end of file diff --git a/src/main/resources/jsv-messages.properties b/src/main/resources/jsv-messages.properties index 82ec3c927..ac55585c7 100644 --- a/src/main/resources/jsv-messages.properties +++ b/src/main/resources/jsv-messages.properties @@ -1,8 +1,9 @@ $ref = {0}: has an error with ''refs'' -additionalProperties = {0}: is not defined in the schema and the schema does not allow additional properties -allOf = {0}: should be valid to all the schemas {1} -anyOf = {0}: should be valid to any of the schemas {1} -const = {0}: must be a constant value {1} +additionalItems = {0}: index ''{1}'' is not defined in the schema and the schema does not allow additional items +additionalProperties = {0}: property ''{1}'' is not defined in the schema and the schema does not allow additional properties +allOf = {0}: must be valid to all the schemas {1} +anyOf = {0}: must be valid to any of the schemas {1} +const = {0}: must be the constant value {1} contains = {0}: does not contain an element that passes these validations: {2} contains.max = {0}: must contain fewer than {1} element(s) that passes these validations: {2} contains.min = {0}: must contain at least {1} element(s) that passes these validations: {2} @@ -15,34 +16,34 @@ edits = {0}: has an error with ''edits'' enum = {0}: does not have a value in the enumeration {1} exclusiveMaximum = {0}: must have an exclusive maximum value of {1} exclusiveMinimum = {0}: must have an exclusive minimum value of {1} -false = Boolean schema false is not valid +false = {0}: schema for ''{1}'' is false format = {0}: does not match the {1} pattern {2} id = {0}: {1} is an invalid segment for URI {2} -items = {0}: no validator found at this index +items = {0}: index ''{1}'' is not defined in the schema and the schema does not allow additional items maxContains = {0}: must be a non-negative integer in {1} -maxItems = {0}: there must be a maximum of {1} items in the array -maxLength = {0}: may only be {1} characters long -maxProperties = {0}: may only have a maximum of {1} properties +maxItems = {0}: must have a maximum of {1} items in the array +maxLength = {0}: must be at most {1} characters long +maxProperties = {0}: must only have a maximum of {1} properties maximum = {0}: must have a maximum value of {1} minContains = {0}: must be a non-negative integer in {1} minContainsVsMaxContains = {0}: minContains must less than or equal to maxContains in {1} minItems = {0}: expected at least {1} items but found {2} minLength = {0}: must be at least {1} characters long -minProperties = {0}: should have a minimum of {1} properties +minProperties = {0}: must have a minimum of {1} properties minimum = {0}: must have a minimum value of {1} multipleOf = {0}: must be multiple of {1} -not = {0}: should not be valid to the schema {1} -notAllowed = {0}: is not allowed but it is in the data -oneOf = {0}: should be valid to one and only one schema, but {1} are valid +not = {0}: must not be valid to the schema {1} +notAllowed = {0}: property ''{1}'' is not allowed but it is in the data +oneOf = {0}: must be valid to one and only one schema, but {1} are valid pattern = {0}: does not match the regex pattern {1} patternProperties = {0}: has some error with ''pattern properties'' prefixItems = {0}: no validator found at this index properties = {0}: has an error with ''properties'' -propertyNames = Property name {0} is not valid for validation: {1} +propertyNames = {0}: property ''{1}'' name is not valid: {2} readOnly = {0}: is a readonly field, it cannot be changed required = {0}: required property ''{1}'' not found type = {0}: {1} found, {2} expected -unevaluatedItems = {0}: item ''{1}'' must not be unevaluated or must match unevaluated items schema +unevaluatedItems = {0}: index ''{1}'' must not be unevaluated or must match unevaluated items schema unevaluatedProperties = {0}: property ''{1}'' must not be unevaluated unionType = {0}: {1} found, but {2} is required uniqueItems = {0}: the items in the array must be unique diff --git a/src/main/resources/jsv-messages_ar_EG.properties b/src/main/resources/jsv-messages_ar_EG.properties index c8e24cf77..d04e3b813 100644 --- a/src/main/resources/jsv-messages_ar_EG.properties +++ b/src/main/resources/jsv-messages_ar_EG.properties @@ -1,4 +1,5 @@ $ref= +additionalItems= additionalProperties= allOf= anyOf= diff --git a/src/main/resources/jsv-messages_cs_CZ.properties b/src/main/resources/jsv-messages_cs_CZ.properties index cf9855bba..73e70905a 100644 --- a/src/main/resources/jsv-messages_cs_CZ.properties +++ b/src/main/resources/jsv-messages_cs_CZ.properties @@ -1,5 +1,6 @@ $ref = {0}: obsahuje chybu s ''refs'' -additionalProperties = {0}.{1}: nen definovno ve schmatu a schma neumo??uje dal? vlastnosti +additionalItems = {0}: [{1}] v tomto indexu nebyl nalezen ?dn validtor +additionalProperties = {0}: ''{1}'' nen definovno ve schmatu a schma neumo??uje dal? vlastnosti allOf = {0}: m?lo by bt platn pro v?echna schmata {1} anyOf = {0}: m?lo by bt platn pro kterkoli ze schmat {1} const = {0}: mus bt konstantn hodnota {1} @@ -15,10 +16,10 @@ edits = {0}: obsahuje chybu s '' enum = {0}: nem hodnotu ve v?tu {1} exclusiveMaximum = {0}: mus mt exkluzivn maximln hodnotu {1} exclusiveMinimum = {0}: mus mt exkluzivn minimln hodnotu {1} -false = Booleovsk schma false nen platn +false = {0}: Booleovsk schma false nen platn format = {0}: neodpovd vzoru {1} {2} id = {0}: {1} je neplatn segment pro URI {2} -items= {0}[{1}]: v tomto indexu nebyl nalezen ?dn validtor +items= {0}: [{1}] v tomto indexu nebyl nalezen ?dn validtor maxContains = {0}: mus bt nezporn cel ?slo v {1} maxItems = {0}: v poli mus bt maximln? {1} polo?ek maxLength = {0}: m??e mt pouze {1} znak? @@ -32,18 +33,18 @@ minProperties = {0}: m?l by m minimum = {0}: mus mt minimln hodnotu {1} multipleOf = {0}: mus bt nsobkem {1} not = {0}: nem?lo by bt platn pro schma {1} -notAllowed = {0}.{1}: nen povoleno, ale je v datech +notAllowed = {0}: ''{1}'' nen povoleno, ale je v datech oneOf = {0}: m?l by bt platn pro jedno a pouze jedno schma, ale {1} jsou platn pattern = {0}: neodpovd vzoru regulrnho vrazu {1} patternProperties = {0}: obsahuje n?jakou chybu ve vlastnostech vzoru -prefixItems = {0}[{1}]: v tomto indexu nebyl nalezen ?dn validtor +prefixItems = {0}: [{1}] v tomto indexu nebyl nalezen ?dn validtor properties = {0}: obsahuje chybu s vlastnostmi -propertyNames = Nzev vlastnosti {0} nen platn pro ov??en: {1} +propertyNames = {0}: ''{1}'' Nzev vlastnosti {0} nen platn pro ov??en: {1} readOnly = {0}: je pole pouze pro ?ten, nelze jej zm?nit -required = {0}.{1}: chyb, ale je povinn +required = {0}: ''{1}'' chyb, ale je povinn type = {0}: nalezeno {1}, o?ekvno {2} -unevaluatedItems = Na nsledujcch cestch jsou neohodnocen polo?ky {0} -unevaluatedProperties = Na nsledujcch cestch jsou neohodnocen vlastnosti {0} +unevaluatedItems = {0}: ''{1}'' Na nsledujcch cestch jsou neohodnocen polo?ky {0} +unevaluatedProperties = {0}: ''{1}'' Na nsledujcch cestch jsou neohodnocen vlastnosti {0} unionType = {0}: nalezeno {1}, ale je vy?adovno {2} uniqueItems = {0}: polo?ky v poli mus bt jedine?n uuid = {0}: {1} je neplatn {2} diff --git a/src/main/resources/jsv-messages_da_DK.properties b/src/main/resources/jsv-messages_da_DK.properties index c162bc0a2..bef3222f2 100644 --- a/src/main/resources/jsv-messages_da_DK.properties +++ b/src/main/resources/jsv-messages_da_DK.properties @@ -1,5 +1,6 @@ $ref = {0}: har en fejl med ''refs'' -additionalProperties = {0}.{1}: er ikke defineret i skemaet, og skemaet tillader ikke yderligere egenskaber +additionalItems = {0}: [{1}] ingen validator fundet i dette indeks +additionalProperties = {0}: ''{1}'' er ikke defineret i skemaet, og skemaet tillader ikke yderligere egenskaber allOf = {0}: br vre gyldig for alle skemaerne {1} anyOf = {0}: br vre gyldig for et hvilket som helst af skemaerne {1} const = {0}: skal vre en konstant vrdi {1} @@ -15,10 +16,10 @@ edits = {0}: har en fejl med ''redigeringer'' enum = {0}: har ikke en vrdi i opregningen {1} exclusiveMaximum = {0}: skal have en eksklusiv maksimumvrdi p {1} exclusiveMinimum = {0}: skal have en eksklusiv minimumsvrdi p {1} -false = Boolesk skema falsk er ikke gyldigt +false = {0}: Boolesk skema falsk er ikke gyldigt format = {0}: matcher ikke {1}-mnsteret {2} id = {0}: {1} er et ugyldigt segment for URI {2} -items = {0}[{1}]: ingen validator fundet i dette indeks +items = {0}: [{1}] ingen validator fundet i dette indeks maxContains = {0}: skal vre et ikke-negativt heltal i {1} maxItems = {0}: der m maksimalt vre {1} elementer i arrayet maxLength = {0}: m kun vre p {1} tegn @@ -32,18 +33,18 @@ minProperties = {0}: skal have mindst {1} egenskaber minimum = {0}: skal have en minimumsvrdi p {1} multipleOf = {0}: skal vre multiplum af {1} not = {0}: br ikke vre gyldig for skemaet {1} -notAllowed = {0}.{1}: er ikke tilladt, men det er i dataene +notAllowed = {0}: ''{1}'' er ikke tilladt, men det er i dataene oneOf = {0}: br vre gyldig for t og kun t skema, men {1} er gyldige pattern = {0}: matcher ikke regex-mnsteret {1} patternProperties = {0}: har en fejl med ''mnsteregenskaber'' -prefixItems = {0}[{1}]: ingen validator fundet i dette indeks +prefixItems = {0}: [{1}] ingen validator fundet i dette indeks properties = {0}: har en fejl med ''egenskaber'' -propertyNames = Ejendomsnavnet {0} er ikke gyldigt til validering: {1} +propertyNames = {0}: ''{1}'' Ejendomsnavnet {0} er ikke gyldigt til validering: {1} readOnly = {0}: er et skrivebeskyttet felt, det kan ikke ndres -required = {0}.{1}: mangler, men det er pkrvet +required = {0}: ''{1}'' mangler, men det er pkrvet type = {0}: {1} fundet, {2} forventet -unevaluatedItems = Der er ikke-evaluerede varer p flgende stier {0} -unevaluatedProperties = Der er ikke-evaluerede egenskaber ved flgende stier {0} +unevaluatedItems = {0}: ''{1}'' Der er ikke-evaluerede varer p flgende stier {0} +unevaluatedProperties = {0}: ''{1}'' Der er ikke-evaluerede egenskaber ved flgende stier {0} unionType = {0}: {1} fundet, men {2} er pkrvet uniqueItems = {0}: Elementerne i arrayet skal vre unikke uuid = {0}: {1} er en ugyldig {2} diff --git a/src/main/resources/jsv-messages_de.properties b/src/main/resources/jsv-messages_de.properties index cad9df48a..47101f119 100644 --- a/src/main/resources/jsv-messages_de.properties +++ b/src/main/resources/jsv-messages_de.properties @@ -1,43 +1,44 @@ $ref = {0}: Ein Fehler mit ''refs'' ist aufgetreten -additionalProperties = {0}.{1} ist nicht im Schema definiert und das Schema verbietet ''additionalProperties'' -allOf = {0} muss gltig fr alle Schemata {1} sein -anyOf = {0} muss gltig fr mindestens ein Schema {1} sein -const = {0} muss den konstanten Wert {1} annehmen -contains = {0} beinhaltet kein Element, das diese Validierung besteht: {2} +additionalItems = {0}: [{1}] Kein Validator an diesem Index gefunden +additionalProperties = {0}: ''{1}'' ist nicht im Schema definiert und das Schema verbietet ''additionalProperties'' +allOf = {0}: muss gltig fr alle Schemata {1} sein +anyOf = {0}: muss gltig fr mindestens ein Schema {1} sein +const = {0}: muss den konstanten Wert {1} annehmen +contains = {0}: beinhaltet kein Element, das diese Validierung besteht: {2} crossEdits = {0}: Ein Fehler mit ''cross edits'' ist aufgetreten dateTime = {0}: {1} ist ein ungltiges {2} -dependencies = {0} hat einen Fehler mit Abhngigkeiten {1} -dependentRequired = {0} fehlt eine Eigenschaft, welche ''dependentRequired'' {1} ist +dependencies = {0}: hat einen Fehler mit Abhngigkeiten {1} +dependentRequired = {0}: fehlt eine Eigenschaft, welche ''dependentRequired'' {1} ist dependentSchemas = {0}: Ein Fehler mit ''dependentSchemas'' {1} ist aufgetreten edits = {0}: Ein Fehler mit ''edits'' ist aufgetreten enum = {0}: Ein Wert in der Aufzhlung {1} fehlt -exclusiveMaximum = {0} muss grer sein als {1} -exclusiveMinimum = {0} muss kleiner sein als {1} -false = Das boolesche Schema ''false'' ist ungltig -format = {0} muss dem Format {1} entsprechen {2} +exclusiveMaximum = {0}: muss grer sein als {1} +exclusiveMinimum = {0}: muss kleiner sein als {1} +false = {0}: Das boolesche Schema ''false'' ist ungltig +format = {0}: muss dem Format {1} entsprechen {2} id = {0}: {1} ist ein ungltiges Segment fr die URI {2} -items = {0}[{1}]: Kein Validator an diesem Index gefunden -maxItems = {0} darf hchstens {1} Element(e) beinhalten -maxLength = {0} darf hchstens {1} Zeichen lang sein -maxProperties = {0} darf hchstens {1} Eigenschaft(en) haben -maximum = {0} darf den Wert {1} nicht berschreiten -minItems = {0} muss mindestens {1} Element(e) beinhalten -minLength = {0} muss mindestens {1} Zeichen lang sein -minProperties = {0} muss mindestens {1} Eigenschaft(en) haben -minimum = {0} muss mindestens den Wert {1} haben -multipleOf = {0} muss ein Vielfaches von {1} sein -not = {0} darf nicht gltig sein fr das Schema {1} -notAllowed = {0}.{1} ist nicht erlaubt und darf folglich nicht auftreten -oneOf = {0} sollte fr genau ein Schema gltig sein, aber {1} sind gltig -pattern = {0} stimmt nicht mit dem regulren Ausdruck {1} berein -patternProperties = {0} stimmt nicht berein mit dem Format definiert in ''pattern properties'' +items = {0}: [{1}] Kein Validator an diesem Index gefunden +maxItems = {0}: darf hchstens {1} Element(e) beinhalten +maxLength = {0}: darf hchstens {1} Zeichen lang sein +maxProperties = {0}: darf hchstens {1} Eigenschaft(en) haben +maximum = {0}: darf den Wert {1} nicht berschreiten +minItems = {0}: muss mindestens {1} Element(e) beinhalten +minLength = {0}: muss mindestens {1} Zeichen lang sein +minProperties = {0}: muss mindestens {1} Eigenschaft(en) haben +minimum = {0}: muss mindestens den Wert {1} haben +multipleOf = {0}: muss ein Vielfaches von {1} sein +not = {0}: darf nicht gltig sein fr das Schema {1} +notAllowed = {0}: ''{1}'' ist nicht erlaubt und darf folglich nicht auftreten +oneOf = {0}: sollte fr genau ein Schema gltig sein, aber {1} sind gltig +pattern = {0}: stimmt nicht mit dem regulren Ausdruck {1} berein +patternProperties = {0}: stimmt nicht berein mit dem Format definiert in ''pattern properties'' properties = {0}: Ein Fehler mit ''properties'' ist aufgetreten -propertyNames = Eigenschaftsname {0} ist ungltig fr die Validierung: {1} -readOnly = {0} ist ein schreibgeschtztes Feld und kann nicht verndert werden -required = {0}.{1} ist ein Pflichtfeld aber fehlt +propertyNames = {0}: ''{1}'' Eigenschaftsname {0} ist ungltig fr die Validierung: {1} +readOnly = {0}: ist ein schreibgeschtztes Feld und kann nicht verndert werden +required = {0}: ''{1}'' ist ein Pflichtfeld aber fehlt type = {0}: {1} wurde gefunden, aber {2} erwartet -unevaluatedItems = Elemente in den folgenden Pfaden wurden nicht bewertet: {0} -unevaluatedProperties = Eigenschaften in folgenden Pfaden wurden nicht evaluiert: {0} +unevaluatedItems = {0}: ''{1}''Elemente in den folgenden Pfaden wurden nicht bewertet: {0} +unevaluatedProperties = {0}: ''{1}''Eigenschaften in folgenden Pfaden wurden nicht evaluiert: {0} unionType = {0}: {1} wurde gefunden aber {2} wird verlangt uniqueItems = {0}: Die Element(e) des Arrays drfen nur einmal auftreten uuid = {0}: {1} ist ein ungltiges {2} diff --git a/src/main/resources/jsv-messages_fa_IR.properties b/src/main/resources/jsv-messages_fa_IR.properties index 2274d6353..87b33529f 100644 --- a/src/main/resources/jsv-messages_fa_IR.properties +++ b/src/main/resources/jsv-messages_fa_IR.properties @@ -1,5 +1,6 @@ $ref = {0}: دارای خطا با ''refs'' -additionalProperties = {0}.{1}: در طرحواره تعریف نشده است و طرح ویژگی های اضافی را اجازه نمی دهد +additionalItems = {0}: [{1}] هیچ اعتبارسنجی در این فهرست یافت نشد +additionalProperties = {0}: ''{1}'' در طرحواره تعریف نشده است و طرح ویژگی های اضافی را اجازه نمی دهد allOf = {0}: باید برای همه طرحواره ها معتبر باشد {1} anyOf = {0}: باید برای هر یک از طرحواره ها معتبر باشد {1} const = {0}: باید برابر مقدار {1} باشد @@ -13,10 +14,10 @@ edits = {0}: دارای خطا با ''ویرایش ها'' است enum = {0}: مقدار در درون لیست مجازها نیست {1} exclusiveMaximum = {0}: باید حداکثر مقدار مطلق داشته باشد {1} exclusiveMinimum = {0}: باید حداقل مقدار انحصاری داشته باشد {1} -false = طرحواره بولی نادرست معتبر نیست +false = {0}: طرحواره بولی نادرست معتبر نیست format = {0}: با الگوی {1} {2} مطابقت ندارد id = {0}: {1} یک بخش نامعتبر برای URI {2} است -items = {0}[{1}]: هیچ اعتبارسنجی در این فهرست یافت نشد +items = {0}: [{1}] هیچ اعتبارسنجی در این فهرست یافت نشد maxItems = {0}: باید حداکثر {1} مورد در آرایه وجود داشته باشد maxLength = {0}: ممکن است فقط {1} کاراکتر باشد maxProperties = {0}: ممکن است فقط حداکثر {1} ویژگی داشته باشد @@ -27,18 +28,18 @@ minProperties = {0}: should have a minimum of {1} properties minimum = {0}: باید حداقل {1} ویژگی داشته باشد multipleOf = {0}: باید مضرب از {1} باشد not = {0}: نباید برای طرحواره معتبر باشد {1} -notAllowed = {0}.{1}: مجاز نیست اما در داده ها وجود دارد +notAllowed = {0}: ''{1}'' مجاز نیست اما در داده ها وجود دارد # needs to be re-worked by a native speaker #oneOf = {0}: باید برای یک و تنها یکی از طرحواره ها معتبر باشد، اما بیش از یکی معتبر است: {1} pattern = {0}: با الگوی regex مطابقت ندارد {1} patternProperties = {0}: دارای مقداری خطا با ''خواص الگو'' -prefixItems = {0}[{1}]: هیچ اعتبارسنجی در این فهرست یافت نشد +prefixItems = {0}: [{1}] هیچ اعتبارسنجی در این فهرست یافت نشد properties = {0}: دارای خطا با ''خواص'' -propertyNames = نام مشخصه {0} برای اعتبارسنجی معتبر نیست: {1} +propertyNames = {0}: ''{1}'' نام مشخصه {0} برای اعتبارسنجی معتبر نیست: {1} readOnly = {0}: یک فیلد فقط خواندنی است، نمی توان آن را تغییر داد -required = {0}.{1}: وجود ندارد اما لازم است +required = {0}: ''{1}'' وجود ندارد اما لازم است type = {0}: {1} یافت شد، {2} مورد انتظار بود -unevaluatedProperties = ویژگی های ارزیابی نشده در مسیرهای زیر وجود دارد {0} +unevaluatedProperties = {0}: ''{1}'' ویژگی های ارزیابی نشده در مسیرهای زیر وجود دارد unionType = {0}: {1} پیدا شد، اما {2} مورد نیاز است uniqueItems = {0}: موارد موجود در آرایه باید منحصر به فرد باشند uuid = {0}: {1} یک {2} نامعتبر است diff --git a/src/main/resources/jsv-messages_fi_FI.properties b/src/main/resources/jsv-messages_fi_FI.properties index 64561cb6c..3467df016 100644 --- a/src/main/resources/jsv-messages_fi_FI.properties +++ b/src/main/resources/jsv-messages_fi_FI.properties @@ -1,5 +1,6 @@ $ref = {0}: siin on virhe koskien ''refs'' -additionalProperties = {0}.{1}: ei ole mritetty skeemassa, eik skeema salli lisominaisuuksia +additionalItems = {0}: [{1}] tst hakemistosta ei lytynyt vahvistusta +additionalProperties = {0}: ''{1}'' ei ole mritetty skeemassa, eik skeema salli lisominaisuuksia allOf = {0}: pitisi olla voimassa kaikissa malleissa {1} anyOf = {0}: pitisi olla voimassa miss tahansa skeemassa {1} const = {0}: on oltava vakioarvo {1} @@ -15,10 +16,10 @@ edits = {0}: sis enum = {0}: sill ei ole arvoa luettelossa {1} exclusiveMaximum = {0}: eksklusiivisen enimmisarvon on oltava {1} exclusiveMinimum = {0}: on oltava yksinomainen vhimmisarvo {1} -false = Boolen skeema false ei kelpaa +false = {0}: Boolen skeema false ei kelpaa format = {0}: ei vastaa mallia {1} {2} id = {0}: {1} on virheellinen segmentti URI:lle {2} -items = {0}[{1}]: tst hakemistosta ei lytynyt vahvistusta +items = {0}: [{1}] tst hakemistosta ei lytynyt vahvistusta maxContains = {0}: on oltava ei-negatiivinen kokonaisluku ryhmss {1} maxItems = {0}: taulukossa saa olla enintn {1} kohdetta maxLength = {0}: voi olla vain {1} merkki pitk @@ -32,18 +33,18 @@ minProperties = {0}: sis minimum = {0}: vhimmisarvon on oltava {1} multipleOf = {0}: tytyy olla {1}:n kerrannainen not = {0}: ei pitisi olla kelvollinen kaavalle {1} -notAllowed = {0}.{1}: ei ole sallittu, mutta se on tiedoissa +notAllowed = {0}: ''{1}'' ei ole sallittu, mutta se on tiedoissa oneOf = {0}: pitisi olla voimassa vain yhdelle skeemalle, mutta {1} ovat kelvollisia pattern = {0}: ei vastaa snnllisen lausekkeen mallia {1} patternProperties = {0}: siin on virhe kuvion ominaisuuksissa -prefixItems = {0}[{1}]: tst hakemistosta ei lydy vahvistusta +prefixItems = {0}: [{1}] tst hakemistosta ei lydy vahvistusta properties = {0}: siin on virhe ''ominaisuuksissa'' -propertyNames = Kiinteistn nimi {0} ei kelpaa vahvistusta varten: {1} +propertyNames = {0}: ''{1}'' Kiinteistn nimi {0} ei kelpaa vahvistusta varten: {1} readOnly = {0}: on vain luku -kentt, sit ei voi muuttaa -required = {0}.{1}: puuttuu, mutta se on pakollinen +required = {0}: ''{1}'' puuttuu, mutta se on pakollinen type = {0}: {1} lydetty, {2} odotettu -unevaluatedItems = Seuraavilla poluilla on arvioimattomia kohteita {0} -unevaluatedProperties = Seuraavilla poluilla on arvioimattomia ominaisuuksia {0} +unevaluatedItems = {0}: ''{1}'' Seuraavilla poluilla on arvioimattomia kohteita {0} +unevaluatedProperties = {0}: ''{1}'' Seuraavilla poluilla on arvioimattomia ominaisuuksia {0} unionType = {0}: {1} lytyi, mutta {2} vaaditaan uniqueItems = {0}: taulukon kohteiden on oltava yksilllisi uuid = {0}: {1} on virheellinen {2} diff --git a/src/main/resources/jsv-messages_fr.properties b/src/main/resources/jsv-messages_fr.properties index 302b15f3b..3e4b7856e 100644 --- a/src/main/resources/jsv-messages_fr.properties +++ b/src/main/resources/jsv-messages_fr.properties @@ -1,12 +1,13 @@ $ref = {0}: a une erreur avec ''refs'' -additionalProperties = {0}.{1} n''est pas dfini dans le schma et le schma n''autorise pas de proprits supplmentaires +additionalItems = {0}: l'index ''{1}'' n'est pas dfini dans le schma et le schma n'autorise pas d'lments supplmentaires +additionalProperties = {0}: ''{1}'' n''est pas dfini dans le schma et le schma n''autorise pas de proprits supplmentaires allOf = {0}: devrait tre valide pour tous les schmas de {1} anyOf = {0}: devrait tre valide pour au moins un schma de {1} const = {0}: doit tre une valeur constante {1} contains = {0}: ne contient pas un lment qui passe ces validations: {2} crossEdits = {0}: a une erreur avec ''cross edits'' dateTime = {0}: {1} n''est pas valide {2} -dependencies = {0} a une erreur avec les dpendances {1} +dependencies = {0}: a une erreur avec les dpendances {1} dependentRequired = {0}: a une proprit manquante qui est ''dependentRequired'' {1} dependentSchemas = {0}: a une erreur avec ''dependentSchemas'' {1} edits = {0}: a une erreur avec ''edits'' @@ -16,7 +17,7 @@ exclusiveMinimum = {0}: doit avoir une valeur minimale exclusive de {1} false = Le schma du boolean "false" n''est pas valide format = {0}: ne correspond pas {1} du modle {2} id = {0}: {1} est un segment invalide pour l''URI {2} -items = {0}[{1}]: Aucun validateur trouv sur cet index +items = {0}: [{1}] Aucun validateur trouv sur cet index maxItems = {0}: doit avoir un maximum de {1} lments dans le tableau maxLength = {0}: ne doit pas dpasser {1} caractres maxProperties = {0}: peut avoir au plus {1} proprits @@ -27,16 +28,17 @@ minProperties = {0}: doit avoir au moins {1} propri minimum = {0}: doit avoir une valeur minimale de {1} multipleOf = {0}: doit tre un multiple de {1} not = {0}: ne doit pas tre valide pour le schma {1} -notAllowed = {0}.{1} n''est pas autoris mais est dans les donnes +notAllowed = {0}: ''{1}'': n''est pas autoris mais est dans les donnes oneOf = {0}: doit tre valide pour un et un seul schma, mais {1} sont valides -pattern = {0} ne correspond pas l''expression rgulire {1} +pattern = {0}: ne correspond pas l''expression rgulire {1} patternProperties = {0}: a des erreurs avec ''pattern properties'' -properties = {0} : a une erreur avec ''properties'' -propertyNames = Le nom de la proprit {0} ne valide pas: {1} +properties = {0}: a une erreur avec ''properties'' +propertyNames = {0}: ''{1}'' Le nom de la proprit {0} ne valide pas: {1} readOnly = {0}: est un champ en lecture seule et ne peut pas tre modifi -required = {0}.{1} est un champ obligatoire mais manquant +required = {0}: ''{1}'' est un champ obligatoire mais manquant type = {0}: {1} a t trouv, mais {2} est attendu -unevaluatedProperties = Des proprits sont non values dans les chemins suivants {0} +unevaluatedItems = {0}: l'index ''{1}'' ne doit pas tre non valu ou doit correspondre au schma des lments non valus +unevaluatedProperties = {0}: ''{1}'' Des proprits sont non values dans les chemins suivants {0} unionType = {0} : {1} trouv, mais {2} est requis uniqueItems = {0}: les lments du tableau doivent tre uniques uuid = {0}: {1} n''est pas valide {2} diff --git a/src/main/resources/jsv-messages_fr_CA.properties b/src/main/resources/jsv-messages_fr_CA.properties index 7028ebcb3..29fba8f08 100644 --- a/src/main/resources/jsv-messages_fr_CA.properties +++ b/src/main/resources/jsv-messages_fr_CA.properties @@ -1,5 +1,6 @@ $ref = {0} : a une erreur avec ''refs'' -additionalProperties = {0}.{1} : n''est pas dfini dans le schma et le schma n''autorise pas les proprits supplmentaires +additionalItems = {0} : [{1}] aucun validateur trouv cet index +additionalProperties = {0} : ''{1}'' n''est pas dfini dans le schma et le schma n''autorise pas les proprits supplmentaires allOf = {0} : doit tre valide pour tous les schmas {1} anyOf = {0} : doit tre valide pour l''un des schmas {1} const = {0} : doit tre une valeur constante {1} @@ -15,7 +16,7 @@ edits = {0} : a une erreur avec ''edits'' enum = {0} : n''a pas de valeur dans l''numration {1} exclusiveMaximum = {0} : doit avoir une valeur maximale exclusive de {1} exclusiveMinimum = {0} : doit avoir une valeur minimale exclusive de {1} -false = le schma boolen false n''est pas valide +false = {0} : le schma boolen false n''est pas valide format = {0} : ne correspond pas au modle {1} {2} id = {0} : {1} est un segment non valide pour l''URI {2} items = {0}[{1}] : aucun validateur trouv cet index @@ -32,18 +33,18 @@ minProperties = {0} : doit avoir un minimum de {1} propri minimum = {0} : doit avoir une valeur minimale de {1} multipleOf = {0} : doit tre un multiple de {1} not = {0} : ne doit pas tre valide pour le schma {1} -notAllowed = {0}.{1} : n''est pas autoris mais il est dans les donnes +notAllowed = {0} : ''{1}'' n''est pas autoris mais il est dans les donnes oneOf = {0} : doit tre valide pour un et un seul schma, mais {1} sont valides pattern = {0} : ne correspond pas au modle regex {1} patternProperties = {0} : a une erreur avec les ''proprits du modle'' -prefixItems = {0}[{1}] : aucun validateur trouv cet index +prefixItems = {0} : [{1}] aucun validateur trouv cet index properties = {0} : a une erreur avec ''proprits'' -propertyNames = Le nom de la proprit {0} n''est pas valide pour la validation : {1} +propertyNames = {0} : ''{1}'' Le nom de la proprit {0} n''est pas valide pour la validation : {1} readOnly = {0} : est un champ en lecture seule, il ne peut pas tre modifi -required = {0}.{1} : manque mais est obligatoire +required = {0} : ''{1}'' manque mais est obligatoire type = {0} : {1} trouv, {2} attendu -unevaluatedItems=Il y a des lments non valus dans les chemins suivants {0} -unevaluatedProperties=Il y a des proprits non values aux chemins suivants {0} +unevaluatedItems= {0} : {1} Il y a des lments non valus dans les chemins suivants {0} +unevaluatedProperties= {0} : {1} Il y a des proprits non values aux chemins suivants {0} unionType = {0} : {1} trouv, mais {2} est requis uniqueItems = {0} : les lments du tableau doivent tre uniques uuid = {0} : {1} est un {2} invalide diff --git a/src/main/resources/jsv-messages_he_IL.properties b/src/main/resources/jsv-messages_he_IL.properties index 540fb13c8..0f98f742e 100644 --- a/src/main/resources/jsv-messages_he_IL.properties +++ b/src/main/resources/jsv-messages_he_IL.properties @@ -1,5 +1,6 @@ $ref = {0}: יש שגיאה עם ''refs'' -additionalProperties = {0}.{1}: אינו מוגדר בסכימה והסכימה אינה מאפשרת מאפיינים נוספים +additionalItems = {0}: [{1}] לא נמצא מאמת באינדקס זה +additionalProperties = {0}: ''{1}'' אינו מוגדר בסכימה והסכימה אינה מאפשרת מאפיינים נוספים allOf = {0}: צריך להיות חוקי לכל הסכמות {1} anyOf = {0}: צריך להיות חוקי לכל אחת מהסכימות {1} const = {0}: חייב להיות ערך קבוע {1} @@ -15,10 +16,10 @@ edits = {0}: יש שגיאה עם ''עריכות'' enum = {0}: אין ערך בספירה {1} exclusiveMaximum = {0}: חייב להיות בעל ערך מקסימלי בלעדי של {1} exclusiveMinimum = {0}: חייב להיות בעל ערך מינימלי בלעדי של {1} -false = סכימה בוליאנית false אינה חוקית +false = {0}: סכימה בוליאנית false אינה חוקית format = {0}: אינו תואם לתבנית {1} {2} id = {0}: {1} הוא פלח לא חוקי עבור URI {2} -items = {0}[{1}]: לא נמצא מאמת באינדקס זה +items = {0}: [{1}] לא נמצא מאמת באינדקס זה maxContains = {0}: חייב להיות מספר שלם לא שלילי ב-{1} maxItems = {0}: חייבים להיות מקסימום של {1} פריטים במערך maxLength = {0}: עשוי להיות באורך של {1} תווים בלבד @@ -32,18 +33,18 @@ minProperties = {0}: צריך להיות לפחות {1} מאפיינים minimum = {0}: חייב להיות בעל ערך מינימלי של {1} multipleOf = {0}: חייב להיות כפולה של {1} not = {0}: לא אמור להיות חוקי לסכימה {1} -notAllowed = {0}.{1}: אסור אבל הוא נמצא בנתונים +notAllowed = {0}: ''{1}'' אסור אבל הוא נמצא בנתונים oneOf = {0}: צריך להיות חוקי לסכימה אחת ויחידה, אבל {1} חוקיים pattern = {0}: אינו תואם לתבנית הביטוי הרגולרי {1} patternProperties = {0}: יש שגיאה כלשהי עם ''מאפייני דפוס'' -prefixItems = {0}[{1}]: לא נמצא מאמת באינדקס זה +prefixItems = {0}: [{1}] לא נמצא מאמת באינדקס זה properties = {0}: יש שגיאה עם ''מאפיינים'' -propertyNames = שם הנכס {0} אינו חוקי לאימות: {1} +propertyNames = {0}: ''{1}'' שם הנכס {0} אינו חוקי לאימות: {1} readOnly = {0}: הוא שדה לקריאה בלבד, לא ניתן לשנות אותו -required = {0}.{1}: חסר אך נדרש +required = {0}: ''{1}'' חסר אך נדרש type = {0}: {1} נמצא, {2} צפוי -unevaluatedItems = ישנם פריטים לא מוערכים בנתיבים הבאים {0} -unevaluatedProperties = ישנם מאפיינים לא מוערכים בנתיבים הבאים {0} +unevaluatedItems = {0}: ''{1}'' ישנם פריטים לא מוערכים בנתיבים הבאים {0} +unevaluatedProperties = {0}: ''{1}'' ישנם מאפיינים לא מוערכים בנתיבים הבאים {0} unionType = {0}: נמצא {1}, אך נדרש {2} uniqueItems = {0}: הפריטים במערך חייבים להיות ייחודיים uuid = {0}: {1} הוא {2} לא חוקי diff --git a/src/main/resources/jsv-messages_hr_HR.properties b/src/main/resources/jsv-messages_hr_HR.properties index f86431817..04b179369 100644 --- a/src/main/resources/jsv-messages_hr_HR.properties +++ b/src/main/resources/jsv-messages_hr_HR.properties @@ -1,5 +1,6 @@ $ref = {0}: ima pogre?ku s ''refs'' -additionalProperties = {0}.{1}: nije definirano u shemi i shema ne dopu?ta dodatna svojstva +additionalItems = {0}: [{1}] u ovom indeksu nije prona?en validator +additionalProperties = {0}: ''{1}'' nije definirano u shemi i shema ne dopu?ta dodatna svojstva allOf = {0}: trebalo bi biti va?e?e za sve sheme {1} anyOf = {0}: trebalo bi biti va?e?e za bilo koju od shema {1} const = {0}: mora biti konstantna vrijednost {1} @@ -15,10 +16,10 @@ edits= {0}: ima pogre?ku s ''ure?ivanja'' enum = {0}: nema vrijednost u enumeraciji {1} exclusiveMaximum = {0}: mora imati isklju?ivu maksimalnu vrijednost od {1} exclusiveMinimum = {0}: mora imati isklju?ivu minimalnu vrijednost od {1} -false = Booleova shema false nije va?e?a +false = {0}: Booleova shema false nije va?e?a format = {0}: ne odgovara {1} uzorku {2} id = {0}: {1} je neva?e?i segment za URI {2} -items = {0}[{1}]: u ovom indeksu nije prona?en validator +items = {0}: [{1}] u ovom indeksu nije prona?en validator maxContains = {0}: mora biti nenegativan cijeli broj u {1} maxItems = {0}: mora postojati najvi?e {1} stavki u nizu maxLength = {0}: mo?e imati samo {1} znakova @@ -32,18 +33,18 @@ minProperties = {0}: treba imati najmanje {1} svojstava minimum = {0}: mora imati minimalnu vrijednost od {1} multipleOf = {0}: mora biti vi?estruko od {1} not = {0}: ne bi trebalo biti va?e?e za shemu {1} -notAllowed = {0}.{1}: nije dopu?teno, ali je u podacima +notAllowed = {0}: ''{1}'' nije dopu?teno, ali je u podacima oneOf = {0}: trebalo bi biti va?e?e za jednu i samo jednu shemu, ali {1} su va?e?e pattern = {0}: ne odgovara uzorku regularnog izraza {1} patternProperties = {0}: ima neke pogre?ke s ''pattern properties'' -prefixItems = {0}[{1}]: u ovom indeksu nije prona?en validator +prefixItems = {0}: [{1}] u ovom indeksu nije prona?en validator properties = {0}: ima gre?ku sa ''svojstvima'' -propertyNames = Ime svojstva {0} nije va?e?e za provjeru: {1} +propertyNames = {0}: ''{1}'' Ime svojstva {0} nije va?e?e za provjeru: {1} readOnly = {0}: polje je samo za ?itanje, ne mo?e se mijenjati -required = {0}.{1}: nedostaje, ali je obavezno +required = {0}: ''{1}'' nedostaje, ali je obavezno type = {0}: {1} prona?eno, {2} o?ekivano -unevaluatedItems = Postoje neprocijenjene stavke na sljede?im stazama {0} -unevaluatedProperties = Postoje neprocijenjena svojstva na sljede?im stazama {0} +unevaluatedItems = {0}: {1} Postoje neprocijenjene stavke na sljede?im stazama {0} +unevaluatedProperties = {0}: {1} Postoje neprocijenjena svojstva na sljede?im stazama {0} unionType = {0}: {1} prona?eno, ali {2} je potrebno uniqueItems = {0}: stavke u nizu moraju biti jedinstvene uuid = {0}: {1} je neva?e?i {2} diff --git a/src/main/resources/jsv-messages_hu_HU.properties b/src/main/resources/jsv-messages_hu_HU.properties index 05eb66e99..ab4e8999f 100644 --- a/src/main/resources/jsv-messages_hu_HU.properties +++ b/src/main/resources/jsv-messages_hu_HU.properties @@ -1,5 +1,6 @@ $ref = {0}: hibs a ''refs'' -additionalProperties = {0}.{1}: nincs megadva a smban, s a sma nem engedlyez tovbbi tulajdonsgokat +additionalItems = {0}: [{1}] ezen az indexen nem tallhat rvnyest? +additionalProperties = {0}: ''{1}'' nincs megadva a smban, s a sma nem engedlyez tovbbi tulajdonsgokat allOf = {0}: rvnyesnek kell lennie az sszes smra {1} anyOf = {0}: rvnyesnek kell lennie a(z) {1} smk brmelyikre const = {0}: lland rtknek kell lennie {1} @@ -15,10 +16,10 @@ edits = {0}: hib enum = {0}: nincs rtke a(z) {1} felsorolsban exclusiveMaximum = {0}: kizrlagos maximlis rtke {1} exclusiveMinimum = {0}: kizrlagos minimlis rtke {1} -false = A false logikai sma nem rvnyes +false = {0}: A false logikai sma nem rvnyes format = {0}: nem egyezik a {1} mintval {2} id = {0}: a(z) {1} rvnytelen szegmens a(z) {2} URI szmra -items = {0}[{1}]: ezen az indexen nem tallhat rvnyest? +items = {0}: [{1}] ezen az indexen nem tallhat rvnyest? maxContains = {0}: egy nem negatv egsz szmnak kell lennie a kvetkez?ben: {1} maxItems = {0}: legfeljebb {1} elem lehet a tmbben maxLength = {0}: csak {1} karakter hosszsg lehet @@ -32,18 +33,18 @@ minProperties = {0}: legal minimum = {0}: legalbb {1} rtkkel kell rendelkeznie multipleOf = {0}: {1} tbbszrsnek kell lennie not = {0}: nem rvnyes a(z) {1} smra -notAllowed = {0}.{1}: nem engedlyezett, de benne van az adatokban +notAllowed = {0}: ''{1}'' nem engedlyezett, de benne van az adatokban oneOf = {0}: egy s csak egy smra rvnyesnek kell lennie, de a {1} rvnyes pattern = {0}: nem egyezik a kvetkez? regex mintval: {1} patternProperties = {0}: hibs a "minta tulajdonsgai" -prefixItems = {0}[{1}]: nem tallhat rvnyest? ezen az indexen +prefixItems = {0}: [{1}] nem tallhat rvnyest? ezen az indexen properties = {0}: hibs a "tulajdonsgok" -propertyNames = A(z) {0} tulajdonnv nem rvnyes az ellen?rzsre: {1} +propertyNames = {0}: ''{1}'' A(z) {0} tulajdonnv nem rvnyes az ellen?rzsre: {1} readOnly = {0}: csak olvashat mez?, nem mdosthat -required = {0}.{1}: hinyzik, de ktelez? +required = {0}: ''{1}'' hinyzik, de ktelez? type = {0}: {1} tallhat, {2} vrhat -unevaluatedItems = A kvetkez? tvonalakon vannak kirtkeletlen elemek: {0} -unevaluatedProperties = A kvetkez? tvonalakon vannak kirtkeletlen tulajdonsgok: {0} +unevaluatedItems = {0}: ''{1}''A kvetkez? tvonalakon vannak kirtkeletlen elemek: {0} +unevaluatedProperties = {0}: ''{1}''A kvetkez? tvonalakon vannak kirtkeletlen tulajdonsgok: {0} unionType = {0}: {1} tallhat, de a {2} megadsa ktelez? uniqueItems = {0}: a tmb elemeinek egyedinek kell lennik uuid = {0}: {1} rvnytelen {2} diff --git a/src/main/resources/jsv-messages_it.properties b/src/main/resources/jsv-messages_it.properties index 6a8bf84d2..d98d11d77 100644 --- a/src/main/resources/jsv-messages_it.properties +++ b/src/main/resources/jsv-messages_it.properties @@ -1,5 +1,6 @@ $ref = {0}: c'' un problema con il tag ''refs'' -additionalProperties = {0}.{1}: non definito nello schema e lo schema non permette properties aggiuntive +additionalItems = {0}: [{1}] nessun validatore trovato all''indice +additionalProperties = {0}: ''{1}'' non definito nello schema e lo schema non permette properties aggiuntive allOf = {0}: dovrebbe essere valido per tutti gli schemas {1} anyOf = {0}: dovrebbe essere valido per uno degli schemas {1} const = {0}: dovrebbe essere un valore costante {1} @@ -13,10 +14,10 @@ edits = {0}: ha un errore con ''edits'' enum = {0}: non ha un valore nell''enumerazione {1} exclusiveMaximum = {0}: deve avere un valore massimo esclusivo di {1} exclusiveMinimum = {0}: deve avere un valore minimo esclusivo di {1} -false = Boolean schema false non valido +false = {0}: Boolean schema false non valido format = {0}: non corrisponde il {1} pattern {2} id = {0}: {1} un segmento invalido per l''URI {2} -items = {0}[{1}]: nessun validatore trovato all''indice +items = {0}: [{1}] nessun validatore trovato all''indice maxItems = {0}: deve esserci un numero massimo di {1} elementi nell''array maxLength = {0}: pu avere lunghezza massima di {1} maxProperties = {0}: pu avere un numero massimo di properties di {1} @@ -27,17 +28,18 @@ minProperties={0}: dovrebbe avere un numero minimo di properties di {1} minimum={0}: deve avere un valore minimo di {1} multipleOf={0}: deve essere un multiplo di {1} not={0}: non dovrebbe essere valido per lo schema {1} -notAllowed={0}.{1}: non consentito ma nel dato +notAllowed={0}: ''{1}'' non consentito ma nel dato oneOf={0}: dovrebbe essere valido per uno e un solo schema, ma {1} sono validi pattern={0}: non corrisponde alla regex {1} patternProperties={0}: ha qualche errore con ''pattern properties'' -prefixItems={0}[{1}]: nessun validatore trovato a quest''indice +prefixItems={0}: [{1}] nessun validatore trovato a quest''indice properties={0}: ha un errore con ''properties'' -propertyNames=Il nome della Property {0} non valido per la validazione: {1} +propertyNames={0}: ''{1}''Il nome della Property {0} non valido per la validazione: {1} readOnly={0}: il campo in sola lettura, non pu essere modificato -required={0}.{1}: obbligatorio ma mancante +required={0}: ''{1}'' obbligatorio ma mancante type={0}: {1} trovato, {2} atteso -unevaluatedProperties=Ci sono properties non valutate nei seguenti percorsi {0} +unevaluatedItems={0}: l'indice ''{1}'' non deve essere valutato o deve corrispondere allo schema degli elementi non valutati +unevaluatedProperties={0}: ''{1}''Ci sono properties non valutate nei seguenti percorsi {0} unionType={0}: {1} trovato, ma {2} obbligatorio uniqueItems={0}: l''elemento nell''array deve essere unico uuid={0}: {1} un invalido {2} diff --git a/src/main/resources/jsv-messages_ja_JP.properties b/src/main/resources/jsv-messages_ja_JP.properties index 297d7e9f3..6d171bd46 100644 --- a/src/main/resources/jsv-messages_ja_JP.properties +++ b/src/main/resources/jsv-messages_ja_JP.properties @@ -1,5 +1,6 @@ $ref = {0}: ''refs'' にエラーがあります -additionalProperties = {0}.{1}: スキーマで定義されておらず、スキーマでは追加のプロパティが許可されていません +additionalItems = {0}: [{1}] このインデックスにバリデータが見つかりません +additionalProperties = {0}: ''{1}'' スキーマで定義されておらず、スキーマでは追加のプロパティが許可されていません allOf = {0}: すべてのスキーマ {1} に対して有効である必要があります anyOf = {0}: スキーマ {1} のいずれかに対して有効である必要があります。 const = {0}: 定数値 {1} である必要があります @@ -15,7 +16,7 @@ edits = {0}: ''edits'' にエラーがあります enum = {0}: 列挙型 {1} に値がありません exclusiveMaximum = {0}: 排他的な最大値は {1} でなければなりません exclusiveMinimum = {0}: 排他的な最小値は {1} でなければなりません -false = ブールスキーマ false は無効です +false = {0}: ブールスキーマ false は無効です format = {0}: {1} パターン {2} に一致しません id = {0}: {1} は URI {2} の無効なセグメントです items = {0}[{1}]: このインデックスにバリデータが見つかりません @@ -36,14 +37,14 @@ notAllowed = {0}.{1}: 許可されていませんが、データ内にありま oneOf = {0}: 1 つのスキーマに対してのみ有効である必要がありますが、{1} は有効です pattern = {0}: 正規表現パターン {1} に一致しません patternProperties = {0}: 「パターン プロパティ」にエラーがあります -prefixItems = {0}[{1}]: このインデックスにバリデータが見つかりません +prefixItems = {0}: [{1}] このインデックスにバリデータが見つかりません properties = {0}: ''プロパティ'' にエラーがあります -propertyNames = プロパティ名 {0} は検証には無効です: {1} +propertyNames = {0}: ''{1}'' プロパティ名 {0} は検証には無効です: {1} readOnly = {0}: は読み取り専用フィールドです。変更できません -required = {0}.{1}: がありませんが、必須です +required = {0}: ''{1}'' がありませんが、必須です type = {0}: {1} が見つかりました、{2} が予期されました -unevaluatedItems = 次のパス {0} に未評価のアイテムがあります -unevaluatedProperties = 次のパス {0} に未評価のプロパティがあります。 +unevaluatedItems = {0}: ''{1}'' 次のパス {0} に未評価のアイテムがあります +unevaluatedProperties = {0}: ''{1}'' 次のパス {0} に未評価のプロパティがあります。 unionType = {0}: {1} が見つかりましたが、{2} が必要です uniqueItems = {0}: 配列内の項目は一意である必要があります uuid = {0}: {1} は無効な {2} です diff --git a/src/main/resources/jsv-messages_ko_KR.properties b/src/main/resources/jsv-messages_ko_KR.properties index d57e1664b..8ab2b6d1b 100644 --- a/src/main/resources/jsv-messages_ko_KR.properties +++ b/src/main/resources/jsv-messages_ko_KR.properties @@ -1,5 +1,6 @@ $ref = {0}: ''refs''에 오류가 있습니다. -additionalProperties = {0}.{1}: 스키마에 정의되어 있지 않으며 스키마에서 추가 속성을 허용하지 않습니다. +additionalItems = {0}: [{1}] 이 색인에서 유효성 검사기를 찾을 수 없습니다. +additionalProperties = {0}: ''{1}'' 스키마에 정의되어 있지 않으며 스키마에서 추가 속성을 허용하지 않습니다. allOf = {0}: 모든 스키마 {1}에 대해 유효해야 합니다. anyOf = {0}: 스키마 {1} 중 하나에 대해 유효해야 합니다. const = {0}: 상수 값이어야 함 {1} @@ -15,10 +16,10 @@ edits = {0}: ''edits''에 오류가 있습니다. enum = {0}: 열거형 {1}에 값이 없습니다. exclusiveMaximum = {0}: {1}의 배타적 최대값을 가져야 합니다. exclusiveMinimum = {0}: 배타적 최소값은 {1}이어야 합니다. -false = 부울 스키마 false가 유효하지 않음 +false = {0}: 부울 스키마 false가 유효하지 않음 format = {0}: {1} 패턴 {2}와 일치하지 않습니다. id = {0}: {1}은(는) URI {2}에 대한 유효하지 않은 세그먼트입니다. -items = {0}[{1}]: 이 색인에서 유효성 검사기를 찾을 수 없습니다. +items = {0}: [{1}] 이 색인에서 유효성 검사기를 찾을 수 없습니다. maxContains = {0}: {1}에서 음수가 아닌 정수여야 합니다. maxItems = {0}: 배열에 최대 {1}개의 항목이 있어야 합니다. maxLength = {0}: 길이는 {1}자만 가능합니다. @@ -32,18 +33,18 @@ minProperties = {0}: 최소 {1}개의 속성이 있어야 합니다. minimum = {0}: 최소값은 {1}이어야 합니다. multipleOf = {0}: {1}의 배수여야 합니다. not = {0}: {1} 스키마에 유효하지 않아야 합니다. -notAllowed = {0}.{1}: 허용되지 않지만 데이터에 있음 +notAllowed = {0}: ''{1}'' 허용되지 않지만 데이터에 있음 oneOf = {0}: 하나의 스키마에만 유효해야 하지만 {1}은 유효합니다. pattern = {0}: 정규식 패턴 {1}과 일치하지 않습니다. patternProperties = {0}: ''패턴 속성''에 일부 오류가 있습니다. -prefixItems = {0}[{1}]: 이 인덱스에서 유효성 검사기를 찾을 수 없습니다. +prefixItems = {0}: [{1}] 이 인덱스에서 유효성 검사기를 찾을 수 없습니다. properties = {0}: ''속성''에 오류가 있습니다. -propertyNames = 속성 이름 {0}은(는) 유효성 검사에 유효하지 않습니다: {1} +propertyNames = {0}: ''{1}'' 속성 이름 {0}은(는) 유효성 검사에 유효하지 않습니다: {1} readOnly = {0}: 읽기 전용 필드이므로 변경할 수 없습니다. -required = {0}.{1}: 누락되었지만 필수입니다. +required = {0}: ''{1}'' 누락되었지만 필수입니다. type = {0}: {1} 발견됨, {2} 예상됨 -unevaluatedItems = 다음 경로에 평가되지 않은 항목이 있습니다 {0} -unevaluatedProperties = 다음 경로에 평가되지 않은 속성이 있습니다 {0} +unevaluatedItems = {0}: ''{1}'' 다음 경로에 평가되지 않은 항목이 있습니다 {0} +unevaluatedProperties = {0}: ''{1}'' 다음 경로에 평가되지 않은 속성이 있습니다 {0} unionType = {0}: {1}이(가) 있지만 {2}이(가) 필요합니다. uniqueItems = {0}: 배열의 항목은 고유해야 합니다. uuid = {0}: {1}은 잘못된 {2}입니다. diff --git a/src/main/resources/jsv-messages_nb_NO.properties b/src/main/resources/jsv-messages_nb_NO.properties index af95d2475..e953e1b86 100644 --- a/src/main/resources/jsv-messages_nb_NO.properties +++ b/src/main/resources/jsv-messages_nb_NO.properties @@ -1,5 +1,6 @@ $ref = {0}: har en feil med ''refs'' -additionalProperties = {0}.{1}: er ikke definert i skjemaet og skjemaet tillater ikke flere egenskaper +aditionalItems = {0}: [{1}] ingen validator funnet i denne indeksen +additionalProperties = {0}: ''{1}'' er ikke definert i skjemaet og skjemaet tillater ikke flere egenskaper allOf = {0}: skal vre gyldig for alle skjemaene {1} anyOf = {0}: br vre gyldig for alle skjemaene {1} const = {0}: m vre en konstant verdi {1} @@ -15,10 +16,10 @@ edits = {0}: har en feil med ''edits'' enum = {0}: har ikke en verdi i oppregningen {1} exclusiveMaximum = {0}: m ha en eksklusiv maksimumsverdi p {1} exclusiveMinimum = {0}: m ha en eksklusiv minimumsverdi p {1} -false = boolsk skjema usann er ikke gyldig +false = {0}: boolsk skjema usann er ikke gyldig format = {0}: samsvarer ikke med {1}-mnsteret {2} id = {0}: {1} er et ugyldig segment for URI {2} -items = {0}[{1}]: ingen validator funnet i denne indeksen +items = {0}: [{1}] ingen validator funnet i denne indeksen maxContains = {0}: m vre et ikke-negativt heltall i {1} maxItems = {0}: det m vre maksimalt {1} elementer i matrisen maxLength = {0}: kan bare vre {1} tegn langt @@ -32,18 +33,18 @@ minProperties = {0}: b minimum = {0}: m ha en minimumsverdi p {1} multipleOf = {0}: m vre multiplum av {1} not = {0}: skal ikke vre gyldig for skjemaet {1} -notAllowed = {0}.{1}: er ikke tillatt, men det er i dataene +notAllowed = {0}: ''{1}'' er ikke tillatt, men det er i dataene oneOf = {0}: skal vre gyldig for ett og bare ett skjema, men {1} er gyldige pattern = {0}: samsvarer ikke med regex-mnsteret {1} patternProperties = {0}: har en feil med ''mnsteregenskaper'' -prefixItems = {0}[{1}]: ingen validator funnet i denne indeksen +prefixItems = {0}: [{1}] ingen validator funnet i denne indeksen properties = {0}: har en feil med ''egenskaper'' -propertyNames = Eiendomsnavnet {0} er ikke gyldig for validering: {1} +propertyNames = {0}: ''{1}'' Eiendomsnavnet {0} er ikke gyldig for validering: {1} readOnly = {0}: er et skrivebeskyttet felt, det kan ikke endres -required = {0}.{1}: mangler, men er pkrevd +required = {0}: ''{1}'' mangler, men er pkrevd type = {0}: {1} funnet, {2} forventet -unevaluatedItems = Det er ikke-evaluerte elementer p flgende stier {0} -unevaluatedProperties = Det er uevaluerte egenskaper ved flgende stier {0} +unevaluatedItems = {0}: ''{1}'' Det er ikke-evaluerte elementer p flgende stier {0} +unevaluatedProperties = {0}: ''{1}'' Det er uevaluerte egenskaper ved flgende stier {0} unionType = {0}: {1} funnet, men {2} kreves uniqueItems = {0}: elementene i matrisen m vre unike uuid = {0}: {1} er en ugyldig {2} diff --git a/src/main/resources/jsv-messages_nl_NL.properties b/src/main/resources/jsv-messages_nl_NL.properties index ec29cbfd3..10462eec2 100644 --- a/src/main/resources/jsv-messages_nl_NL.properties +++ b/src/main/resources/jsv-messages_nl_NL.properties @@ -1,5 +1,6 @@ $ref = {0}: heeft een fout met ''refs'' -additionalProperties = {0}.{1}: is niet gedefinieerd in het schema en het schema staat geen aanvullende eigenschappen toe +additionalItems = {0}: [{1}] geen validator gevonden bij deze index +additionalProperties = {0}: ''{1}'' is niet gedefinieerd in het schema en het schema staat geen aanvullende eigenschappen toe allOf = {0}: zou geldig moeten zijn voor alle schema''s {1} anyOf = {0}: zou geldig moeten zijn voor elk van de schema''s {1} const = {0}: moet een constante waarde zijn {1} @@ -18,7 +19,7 @@ exclusiveMinimum = {0}: moet een exclusieve minimumwaarde hebben van {1} false = Booleaans schema false is niet geldig format = {0}: komt niet overeen met het {1} patroon {2} id = {0}: {1} is een ongeldig segment voor URI {2} -items = {0}[{1}]: geen validator gevonden bij deze index +items = {0}: [{1}] geen validator gevonden bij deze index maxContains = {0}: moet een niet-negatief geheel getal zijn in {1} maxItems = {0}: er mogen maximaal {1} ??items in de array staan maxLength = {0}: mag slechts {1} tekens lang zijn @@ -32,18 +33,18 @@ minProperties = {0}: moet minimaal {1} ??eigenschappen hebben minimum = {0}: moet een minimale waarde hebben van {1} multipleOf = {0}: moet een veelvoud zijn van {1} not = {0}: zou niet geldig moeten zijn voor het schema {1} -notAllowed = {0}.{1}: is niet toegestaan ??maar staat wel in de data -oneOf = {0}: zou geldig moeten zijn voor n en slechts n schema, maar {1} is geldig +notAllowed = {0}: ''{1}'' is niet toegestaan ??maar staat wel in de data +oneOf = {0}: zou geldig moeten zijn voor één en slechts één schema, maar {1} is geldig pattern = {0}: komt niet overeen met het regex-patroon {1} patternProperties = {0}: heeft een fout met ''pattern properties'' -prefixItems = {0}[{1}]: geen validator gevonden bij deze index +prefixItems = {0}: [{1}] geen validator gevonden bij deze index properties = {0}: heeft een fout met ''properties'' -propertyNames = Eigenschapsnaam {0} is niet geldig voor validatie: {1} +propertyNames = {0}: ''{1}'' Eigenschapsnaam {0} is niet geldig voor validatie: {1} readOnly = {0}: is een alleen-lezen veld, het kan niet worden gewijzigd -required = {0}.{1}: ontbreekt maar is vereist +required = {0}: ''{1}'' ontbreekt maar is vereist type = {0}: {1} gevonden, {2} verwacht -unevaluatedItems = Er zijn niet-gevalueerde items op de volgende paden {0} -unevaluatedProperties = Er zijn niet-gevalueerde eigenschappen op de volgende paden {0} +unevaluatedItems = {0}: ''{1}'' Er zijn niet-geëvalueerde items op de volgende paden {0} +unevaluatedProperties = {0}: ''{1}'' Er zijn niet-geëvalueerde eigenschappen op de volgende paden {0} unionType = {0}: {1} gevonden, maar {2} is vereist uniqueItems = {0}: de items in de array moeten uniek zijn uuid = {0}: {1} is een ongeldige {2} diff --git a/src/main/resources/jsv-messages_pl_PL.properties b/src/main/resources/jsv-messages_pl_PL.properties index 9273863b5..1e6a85d9e 100644 --- a/src/main/resources/jsv-messages_pl_PL.properties +++ b/src/main/resources/jsv-messages_pl_PL.properties @@ -1,5 +1,6 @@ $ref = {0}: zawiera błąd z ''refs'' -additionalProperties = {0}.{1}: nie jest zdefiniowane w schemacie, a schemat nie zezwala na dodatkowe właściwości +additionalItems = {0}: [{1}] nie znaleziono walidatora o tym indeksie +additionalProperties = {0}: ''{1}'' nie jest zdefiniowane w schemacie, a schemat nie zezwala na dodatkowe właściwości allOf = {0}: powinien być ważny dla wszystkich schematów {1} anyOf = {0}: powinien być ważny dla dowolnego ze schematów {1} const = {0}: musi być stałą wartością {1} @@ -15,10 +16,10 @@ edits = {0}: zawiera błąd z ''edits'' enum = {0}: nie ma wartości w enumeracji {1} exclusiveMaximum = {0}: musi mieć wyłączną maksymalną wartość {1} exclusiveMinimum = {0}: musi mieć wyłączną minimalną wartość {1} -false = Schemat logiczny false jest nieprawidłowy +false = {0}: Schemat logiczny false jest nieprawidłowy format = {0}: nie pasuje do wzorca {1} {2} id = {0}: {1} to nieprawidłowy segment dla identyfikatora URI {2} -items = {0}[{1}]: nie znaleziono walidatora o tym indeksie +items = {0}: [{1}] nie znaleziono walidatora o tym indeksie maxContains = {0}: musi być nieujemną liczbą całkowitą w {1} maxItems = {0}: w tablicy może znajdować się maksymalnie {1} elementów maxLength = {0}: może mieć tylko {1} znaków @@ -32,18 +33,18 @@ minProperties = {0}: powinien mieć co najmniej {1} właściwości minimum = {0}: musi mieć minimalną wartość {1} multipleOf = {0}: musi być wielokrotnością {1} not = {0}: nie powinno być poprawne dla schematu {1} -notAllowed = {0}.{1}: nie jest dozwolone, ale jest w danych +notAllowed = {0}: ''{1}'' nie jest dozwolone, ale jest w danych oneOf = {0}: powinien być ważny dla jednego i tylko jednego schematu, ale {1} jest ważny pattern = {0}: nie pasuje do wzorca wyrażenia regularnego {1} patternProperties = {0}: wystąpił błąd dotyczący ''patternProperties'' -prefixItems = {0}[{1}]: nie znaleziono walidatora o tym indeksie +prefixItems = {0}: [{1}] nie znaleziono walidatora o tym indeksie properties = {0}: wystąpił błąd dotyczący ''properties'' propertyNames = Nazwa właściwości {0} jest nieprawidłowa do sprawdzenia poprawności: {1} readOnly = {0}: jest polem tylko do odczytu, nie można go zmienić -required = {0}.{1}: brakuje, ale jest wymagane +required = {0}: ''{1}'' brakuje, ale jest wymagane type = {0}: znaleziono {1}, oczekiwano {2} -unevaluatedItems = W następujących ścieżkach znajdują się elementy bez oceny {0} -unevaluatedProperties = Istnieją nieocenione właściwości w następujących ścieżkach {0} +unevaluatedItems = {0}: ''{1}'' W następujących ścieżkach znajdują się elementy bez oceny {0} +unevaluatedProperties = {0}: ''{1}'' Istnieją nieocenione właściwości w następujących ścieżkach {0} unionType = {0}: znaleziono {1}, ale wymagane jest {2} uniqueItems = {0}: elementy w tablicy muszą być unikalne uuid = {0}: {1} jest nieprawidłowym {2} diff --git a/src/main/resources/jsv-messages_pt_BR.properties b/src/main/resources/jsv-messages_pt_BR.properties index f736f84de..c5cf2915f 100644 --- a/src/main/resources/jsv-messages_pt_BR.properties +++ b/src/main/resources/jsv-messages_pt_BR.properties @@ -1,5 +1,6 @@ $ref = {0}: tem um erro com ''refs'' -additionalProperties = {0}.{1}: no est definido no esquema e o esquema no permite propriedades adicionais +additionalItems = {0}: [{1}] nenhum validador encontrado neste ndice +additionalProperties = {0}: ''{1}'' no est definido no esquema e o esquema no permite propriedades adicionais allOf = {0}: deve ser vlido para todos os esquemas {1} anyOf = {0}: deve ser vlido para qualquer um dos esquemas {1} const = {0}: deve ser um valor constante {1} @@ -15,10 +16,10 @@ edits = {0}: tem um erro com ''edi enum = {0}: no tem valor na enumerao {1} exclusiveMaximum = {0}: deve ter um valor mximo exclusivo de {1} exclusiveMinimum = {0}: deve ter um valor mnimo exclusivo de {1} -false = esquema booleano false no vlido +false = {0}: esquema booleano false no vlido format = {0}: no corresponde ao padro {1} {2} id = {0}: {1} um segmento invlido para URI {2} -items = {0}[{1}]: nenhum validador encontrado neste ndice +items = {0}: [{1}] nenhum validador encontrado neste ndice maxContains = {0}: deve ser um inteiro no negativo em {1} maxItems = {0}: deve haver no mximo {1} itens no array maxLength = {0}: pode ter apenas {1} caracteres @@ -32,18 +33,18 @@ minProperties = {0}: deve ter no m minimum = {0}: deve ter um valor mnimo de {1} multipleOf = {0}: deve ser mltiplo de {1} not = {0}: no deve ser vlido para o esquema {1} -notAllowed = {0}.{1}: no permitido, mas est nos dados +notAllowed = {0}: ''{1}''no permitido, mas est nos dados oneOf = {0}: deve ser vlido para um e apenas um esquema, mas {1} so vlidos pattern = {0}: no corresponde ao padro regex {1} patternProperties = {0}: tem algum erro com ''propriedades do padro'' prefixItems = {0}[{1}]: nenhum validador encontrado neste ndice properties = {0}: tem um erro com ''propriedades'' -propertyNames = O nome da propriedade {0} no vlido para validao: {1} +propertyNames = {0}: ''{1}'' O nome da propriedade {0} no vlido para validao: {1} readOnly = {0}: um campo somente leitura, no pode ser alterado -required = {0}.{1}: est faltando, mas obrigatrio +required = {0}: ''{1}'' est faltando, mas obrigatrio type = {0}: {1} encontrado, {2} esperado -unevaluatedItems = Existem itens no avaliados nos seguintes caminhos {0} -unevaluatedProperties = Existem propriedades no avaliadas nos seguintes caminhos {0} +unevaluatedItems = {0}: ''{1}'' Existem itens no avaliados nos seguintes caminhos {0} +unevaluatedProperties = {0}: ''{1}'' Existem propriedades no avaliadas nos seguintes caminhos {0} unionType = {0}: {1} encontrado, mas {2} obrigatrio uniqueItems = {0}: os itens no array devem ser nicos uuid = {0}: {1} um invlido {2} diff --git a/src/main/resources/jsv-messages_ro_RO.properties b/src/main/resources/jsv-messages_ro_RO.properties index 21eab31cd..6c8d21088 100644 --- a/src/main/resources/jsv-messages_ro_RO.properties +++ b/src/main/resources/jsv-messages_ro_RO.properties @@ -1,5 +1,6 @@ $ref = {0}: are o eroare cu ?refs? -additionalProperties = {0}.{1}: nu este definit n schem?, iar schema nu permite propriet??i suplimentare +additionalItems = {0}: [{1}] nu a fost g?sit niciun validator la acest index +additionalProperties = {0}: ''{1}'' nu este definit n schem?, iar schema nu permite propriet??i suplimentare allOf = {0}: ar trebui s? fie valid pentru toate schemele {1} anyOf = {0}: ar trebui s? fie valid pentru oricare dintre schemele {1} const = {0}: trebuie s? fie o valoare constant? {1} @@ -15,10 +16,10 @@ edits = {0}: are o eroare cu ?edit?ri? enum = {0}: nu are o valoare n enumerarea {1} exclusiveMaximum = {0}: trebuie s? aib? o valoare maxim? exclusiv? de {1} exclusiveMinimum = {0}: trebuie s? aib? o valoare minim? exclusiv? de {1} -false = Schema boolean? false nu este valid? +false = {0} Schema boolean? false nu este valid? format = {0}: nu se potrive?te cu modelul {1} ??{2} id = {0}: {1} este un segment nevalid pentru URI {2} -items = {0}[{1}]: nu a fost g?sit niciun validator la acest index +items = {0}: [{1}] nu a fost g?sit niciun validator la acest index maxContains = {0}: trebuie s? fie un num?r ntreg nenegativ n {1} maxItems = {0}: trebuie s? existe maximum {1} elemente n matrice maxLength = {0}: poate avea numai {1} caractere @@ -32,18 +33,18 @@ minProperties = {0}: ar trebui s? aib? minimum {1} propriet??i minimum = {0}: trebuie s? aib? o valoare minim? de {1} multipleOf = {0}: trebuie s? fie multiplu de {1} not = {0}: nu ar trebui s? fie valid pentru schema {1} -notAllowed = {0}.{1}: nu este permis, dar este n date +notAllowed = {0}: ''{1}'' nu este permis, dar este n date oneOf = {0}: ar trebui s? fie valid pentru una ?i doar o schem?, dar {1} sunt valide pattern = {0}: nu se potrive?te cu modelul regex {1} patternProperties = {0}: are o eroare cu ?propriet??ile modelului? -prefixItems = {0}[{1}]: nu a fost g?sit niciun validator la acest index +prefixItems = {0}: [{1}] nu a fost g?sit niciun validator la acest index properties = {0}: are o eroare cu ?propriet??i? -propertyNames = Numele propriet??ii {0} nu este valid pentru validare: {1} +propertyNames = {0}: ''{1}''Numele propriet??ii {0} nu este valid pentru validare: {1} readOnly = {0}: este un cmp numai n citire, nu poate fi modificat -required = {0}.{1}: lipse?te, dar este obligatoriu +required = {0}: ''{1}'' lipse?te, dar este obligatoriu type = {0}: {1} g?sit, {2} a?teptat -unevaluatedItems = Exist? elemente neevaluate pe urm?toarele c?i {0} -unevaluatedProperties = Exist? propriet??i neevaluate la urm?toarele c?i {0} +unevaluatedItems = {0}: ''{1}'' Exist? elemente neevaluate pe urm?toarele c?i {0} +unevaluatedProperties = {0}: ''{1}'' Exist? propriet??i neevaluate la urm?toarele c?i {0} unionType = {0}: {1} g?sit, dar {2} este necesar uniqueItems = {0}: elementele din matrice trebuie s? fie unice uuid = {0}: {1} este un {2} nevalid diff --git a/src/main/resources/jsv-messages_ru_RU.properties b/src/main/resources/jsv-messages_ru_RU.properties index 96679ab73..c3ae57116 100644 --- a/src/main/resources/jsv-messages_ru_RU.properties +++ b/src/main/resources/jsv-messages_ru_RU.properties @@ -1,5 +1,6 @@ $ref = {0}: ошибка с ''refs'' -additionalProperties = {0}.{1}: не определено в схеме, и схема не допускает дополнительных свойств. +additionalItems = {0}: [{1}] по этому индексу не найден валидатор +additionalProperties = {0}: ''{1}'' не определено в схеме, и схема не допускает дополнительных свойств. allOf = {0}: должно быть действительным для всех схем {1} anyOf = {0}: должно быть допустимо для любой из схем {1} const = {0}: должно быть постоянное значение {1} @@ -15,10 +16,10 @@ edits = {0}: есть ошибка с "изменениями" enum = {0}: не имеет значения в перечислении {1} exclusiveMaximum = {0}: должно быть исключительное максимальное значение {1}. exclusiveMinimum = {0}: должно быть эксклюзивное минимальное значение {1}. -false = логическая схема false недействительна +false = {0}: логическая схема false недействительна format = {0}: не соответствует шаблону {1} ​​{2} id = {0}: {1} является недопустимым сегментом для URI {2}. -items = {0}[{1}]: по этому индексу не найден валидатор +items = {0}: [{1}] по этому индексу не найден валидатор maxContains = {0}: должно быть неотрицательным целым числом в {1} maxItems = {0}: в массиве должно быть не более {1} элементов. maxLength = {0}: может содержать только {1} символов. @@ -32,18 +33,18 @@ minProperties = {0}: должно быть не менее {1} свойств. minimum = {0}: должно быть минимальное значение {1} multipleOf = {0}: должно быть кратно {1} not = {0}: не должно соответствовать схеме {1} -notAllowed = {0}.{1}: не разрешено, но есть в данных +notAllowed = {0}: ''{1}'' не разрешено, но есть в данных oneOf = {0}: должен быть действителен для одной и только одной схемы, но допустимы {1} pattern = {0}: не соответствует шаблону регулярного выражения {1} patternProperties = {0}: есть ошибка со "свойствами шаблона" -prefixItems = {0}[{1}]: по этому индексу не найден валидатор. +prefixItems = {0}: [{1}] по этому индексу не найден валидатор. properties = {0}: ошибка со свойствами -propertyNames = Имя свойства {0} недопустимо для проверки: {1} +propertyNames = {0}: ''{1}'' Имя свойства {0} недопустимо для проверки: {1} readOnly = {0}: это поле только для чтения, его нельзя изменить. -required = {0}.{1}: отсутствует, но требуется +required = {0}: ''{1}'' отсутствует, но требуется type = {0}: найдено {1}, ожидается {2} -unevaluatedItems = по следующим путям {0} есть неоцененные элементы -unevaluatedProperties = по следующим путям {0} есть неоцененные свойства +unevaluatedItems = {0}: ''{1}''по следующим путям {0} есть неоцененные элементы +unevaluatedProperties = {0}: ''{1}''по следующим путям {0} есть неоцененные свойства unionType = {0}: найдено {1}, но требуется {2} uniqueItems = {0}: элементы в массиве должны быть уникальными. uuid = {0}: {1} является недопустимым {2} diff --git a/src/main/resources/jsv-messages_sk_SK.properties b/src/main/resources/jsv-messages_sk_SK.properties index 3522c490d..1f698fdac 100644 --- a/src/main/resources/jsv-messages_sk_SK.properties +++ b/src/main/resources/jsv-messages_sk_SK.properties @@ -1,5 +1,6 @@ $ref = {0}: obsahuje chybu s ''refs'' -additionalProperties = {0}.{1}: nie je definovan v schme a schma neumo??uje ?al?ie vlastnosti +additionalItems = {0}: [{1}] v tomto indexe sa nena?iel ?iadny validtor +additionalProperties = {0}: ''{1}'' nie je definovan v schme a schma neumo??uje ?al?ie vlastnosti allOf = {0}: malo by by? platn pre v?etky schmy {1} anyOf = {0}: malo by by? platn pre ktorko?vek schmu {1} const = {0}: mus by? kon?tantn hodnota {1} @@ -15,10 +16,10 @@ edits = {0}: obsahuje chybu s '' enum = {0}: nem hodnotu v enumercii {1} exclusiveMaximum = {0}: mus ma? vlu?n maximlnu hodnotu {1} exclusiveMinimum = {0}: mus ma? vlu?n minimlnu hodnotu {1} -false = Booleovsk schma false nie je platn +false = {0}: Booleovsk schma false nie je platn format = {0}: nezhoduje sa so vzorom {1} {2} id = {0}: {1} je neplatn segment pre URI {2} -items = {0}[{1}]: v tomto indexe sa nena?iel ?iadny validtor +items = {0}: [{1}] v tomto indexe sa nena?iel ?iadny validtor maxContains = {0}: mus by? nezporn cel ?slo v {1} maxItems = {0}: v poli mus by? maximlne {1} polo?iek maxLength = {0}: m?e ma? iba {1} znakov @@ -32,18 +33,18 @@ minProperties = {0}: mal by ma? minim minimum = {0}: mus ma? minimlnu hodnotu {1} multipleOf = {0}: mus by? nsobkom {1} not = {0}: nemalo by by? platn pre schmu {1} -notAllowed = {0}.{1}: nie je povolen, ale je v dajoch +notAllowed = {0}: ''{1}'' nie je povolen, ale je v dajoch oneOf = {0}: malo by by? platn len pre jednu schmu, ale {1} s platn pattern = {0}: nezodpoved vzoru regulrneho vrazu {1} patternProperties = {0}: obsahuje nejak chybu s "vlastnos?ami vzoru" prefixItems = {0}[{1}]: v tomto indexe sa nena?iel ?iadny validtor properties = {0}: obsahuje chybu s ?vlastnos?ami? -propertyNames = Nzov vlastnosti {0} nie je platn pre overenie: {1} +propertyNames = {0}: ''{1}'' Nzov vlastnosti {0} nie je platn pre overenie: {1} readOnly = {0}: je pole len na ?tanie, nemo?no ho zmeni? -required = {0}.{1}: chba, ale je povinn +required = {0}: ''{1}'' chba, ale je povinn type = {0}: njdench {1}, o?akvanch {2} -unevaluatedItems = Na nasledujcich cestch s nehodnoten polo?ky {0} -unevaluatedProperties = Na nasledujcich cestch s nehodnoten vlastnosti {0} +unevaluatedItems = {0}: ''{1}'' Na nasledujcich cestch s nehodnoten polo?ky {0} +unevaluatedProperties = {0}: ''{1}'' Na nasledujcich cestch s nehodnoten vlastnosti {0} unionType = {0}: {1} njden, ale {2} je povinn uniqueItems = {0}: polo?ky v poli musia by? jedine?n uuid = {0}: {1} je neplatn {2} diff --git a/src/main/resources/jsv-messages_sv_SE.properties b/src/main/resources/jsv-messages_sv_SE.properties index 9ff39f2a7..8e5cd2bca 100644 --- a/src/main/resources/jsv-messages_sv_SE.properties +++ b/src/main/resources/jsv-messages_sv_SE.properties @@ -1,5 +1,6 @@ $ref = {0}: har ett fel med ''refs'' -additionalProperties = {0}.{1}: r inte definierat i schemat och schemat tillter inte ytterligare egenskaper +additionalItems = {0}: [{1}] ingen validator hittades i detta index +additionalProperties = {0}: ''{1}'' r inte definierat i schemat och schemat tillter inte ytterligare egenskaper allOf = {0}: br vara giltig fr alla scheman {1} anyOf = {0}: br vara giltigt fr ngot av schemana {1} const = {0}: mste vara ett konstant vrde {1} @@ -15,10 +16,10 @@ edits = {0}: har ett fel med ''edits'' enum = {0}: har inget vrde i upprkningen {1} exclusiveMaximum = {0}: mste ha ett exklusivt maxvrde p {1} exclusiveMinimum = {0}: mste ha ett exklusivt lgsta vrde p {1} -false = Det booleska schemat false r inte giltigt +false = {0}: Det booleska schemat false r inte giltigt format = {0}: matchar inte {1}-mnstret {2} id = {0}: {1} r ett ogiltigt segment fr URI {2} -items = {0}[{1}]: ingen validator hittades i detta index +items = {0}: [{1}] ingen validator hittades i detta index maxContains = {0}: mste vara ett icke-negativt heltal i {1} maxItems = {0}: det mste finnas maximalt {1} objekt i arrayen maxLength = {0}: fr bara vara {1} tecken lng @@ -32,18 +33,18 @@ minProperties = {0}: b minimum = {0}: mste ha ett lgsta vrde p {1} multipleOf = {0}: mste vara multipel av {1} not = {0}: br inte vara giltigt fr schemat {1} -notAllowed = {0}.{1}: r inte tilltet men det finns i data +notAllowed = {0}: ''{1}'' r inte tilltet men det finns i data oneOf = {0}: br vara giltigt fr ett och endast ett schema, men {1} r giltiga pattern = {0}: matchar inte regexmnstret {1} patternProperties = {0}: har ngot fel med ''mnsteregenskaper'' -prefixItems = {0}[{1}]: ingen validator hittades i detta index +prefixItems = {0}: [{1}] ingen validator hittades i detta index properties = {0}: har ett fel med "egenskaper" -propertyNames = Egenskapens namn {0} r inte giltigt fr validering: {1} +propertyNames = {0}: ''{1}'' Egenskapens namn {0} r inte giltigt fr validering: {1} readOnly = {0}: r ett skrivskyddat flt, det kan inte ndras -required = {0}.{1}: saknas men det r obligatoriskt +required = {0}: ''{1}'' saknas men det r obligatoriskt type = {0}: {1} hittades, {2} frvntas -unevaluatedItems = Det finns ej utvrderade objekt p fljande skvgar {0} -unevaluatedProperties = Det finns ej utvrderade egenskaper vid fljande skvgar {0} +unevaluatedItems = {0}: ''{1}'' Det finns ej utvrderade objekt p fljande skvgar {0} +unevaluatedProperties = {0}: ''{1}'' Det finns ej utvrderade egenskaper vid fljande skvgar {0} unionType = {0}: {1} hittades, men {2} krvs uniqueItems = {0}: objekten i arrayen mste vara unika uuid = {0}: {1} r en ogiltig {2} diff --git a/src/main/resources/jsv-messages_th_TH.properties b/src/main/resources/jsv-messages_th_TH.properties index a9b166d6a..8233e9a77 100644 --- a/src/main/resources/jsv-messages_th_TH.properties +++ b/src/main/resources/jsv-messages_th_TH.properties @@ -1,5 +1,6 @@ $ref = {0}: มีข้อผิดพลาดกับ ''refs'' -additionalProperties = {0}.{1}: ไม่ได้กำหนดไว้ในสคีมาและสคีมาไม่อนุญาตให้ใช้คุณสมบัติเพิ่มเติม +additionalItems = {0}: [{1}] ไม่พบตัวตรวจสอบที่ดัชนีนี้ +additionalProperties = {0}: ''{1}'' ไม่ได้กำหนดไว้ในสคีมาและสคีมาไม่อนุญาตให้ใช้คุณสมบัติเพิ่มเติม allOf = {0}: ควรใช้ได้กับสกีมาทั้งหมด {1} anyOf = {0}: ควรใช้ได้กับ schema ใดๆ {1} const = {0}: ต้องเป็นค่าคงที่ {1} @@ -15,10 +16,10 @@ edits = {0}: มีข้อผิดพลาดกับ ''แก้ไข'' enum = {0}: ไม่มีค่าในการแจงนับ {1} exclusiveMaximum = {0}: ต้องมีค่าสูงสุดเฉพาะตัวที่ {1} exclusiveMinimum = {0}: ต้องมีค่าต่ำสุดเฉพาะตัวเป็น {1} -false = บูลีนสคีมาเท็จไม่ถูกต้อง +false = {0}: บูลีนสคีมาเท็จไม่ถูกต้อง format = {0}: ไม่ตรงกับ {1} รูปแบบ {2} id = {0}: {1} เป็นส่วนไม่ถูกต้องสำหรับ URI {2} -items = {0}[{1}]: ไม่พบตัวตรวจสอบที่ดัชนีนี้ +items = {0}: [{1}] ไม่พบตัวตรวจสอบที่ดัชนีนี้ maxContains = {0}: ต้องเป็นจำนวนเต็มที่ไม่เป็นลบใน {1} maxItems = {0}: ต้องมีสูงสุด {1} รายการในอาร์เรย์ maxLength = {0}: มีความยาวเพียง {1} อักขระ @@ -32,18 +33,18 @@ minProperties = {0}: ควรมีคุณสมบัติอย่าง minimum = {0}: ต้องมีค่าขั้นต่ำเป็น {1} multipleOf = {0}: ต้องเป็นทวีคูณของ {1} not = {0}: ไม่ควรใช้ได้กับสคีมา {1} -notAllowed = {0}.{1}: ไม่อนุญาต แต่อยู่ในข้อมูล +notAllowed = {0}: ''{1}'' ไม่อนุญาต แต่อยู่ในข้อมูล oneOf = {0}: ควรใช้ได้กับหนึ่งสคีมาหนึ่งอันเท่านั้น แต่ {1} นั้นถูกต้อง pattern = {0}: ไม่ตรงกับรูปแบบ regex {1} patternProperties = {0}: มีข้อผิดพลาดบางอย่างกับ ''คุณสมบัติรูปแบบ'' -prefixItems = {0}[{1}]: ไม่พบตัวตรวจสอบที่ดัชนีนี้ +prefixItems = {0}: [{1}] ไม่พบตัวตรวจสอบที่ดัชนีนี้ properties = {0}: มีข้อผิดพลาดกับ ''คุณสมบัติ'' propertyNames = ชื่อคุณสมบัติ {0} ไม่ถูกต้องสำหรับการตรวจสอบความถูกต้อง: {1} readOnly = {0}: เป็นฟิลด์แบบอ่านอย่างเดียว ไม่สามารถเปลี่ยนแปลงได้ -required = {0}.{1}: ขาดหายไป แต่จำเป็น +required = {0}: ''{1}'' ขาดหายไป แต่จำเป็น type = {0}: พบ {1}, {2} คาดหวัง -unevaluatedItems = มีรายการที่ยังไม่ได้ประเมินที่พาธต่อไปนี้ {0} -unevaluatedProperties = มีคุณสมบัติที่ไม่ได้รับการประเมินในพาธต่อไปนี้ {0} +unevaluatedItems = {0}: ''{1}'' มีรายการที่ยังไม่ได้ประเมินที่พาธต่อไปนี้ {0} +unevaluatedProperties = {0}: ''{1}'' มีคุณสมบัติที่ไม่ได้รับการประเมินในพาธต่อไปนี้ {0} unionType = {0}: พบ {1} แต่ต้องมี {2} uniqueItems = {0}: รายการในอาร์เรย์ต้องไม่ซ้ำกัน uuid = {0}: {1} เป็น {2} ที่ไม่ถูกต้อง diff --git a/src/main/resources/jsv-messages_tr_TR.properties b/src/main/resources/jsv-messages_tr_TR.properties index 3ec345e1e..66968149e 100644 --- a/src/main/resources/jsv-messages_tr_TR.properties +++ b/src/main/resources/jsv-messages_tr_TR.properties @@ -1,5 +1,6 @@ $ref = {0}: ''refs'' ile ilgili bir hata var -additionalProperties = {0}.{1}: ?emada tan?ml? de?il ve ?ema ek zelliklere izin vermiyor +additionalItems = {0}: [{1}] bu dizinde do?rulay?c? bulunamad? +additionalProperties = {0}: ''{1}'' ?emada tan?ml? de?il ve ?ema ek zelliklere izin vermiyor allOf = {0}: {1} tm ?emalar? iin geerli olmal?d?r anyOf = {0}: {1} ?emalar?ndan herhangi biri iin geerli olmal?d?r const = {0}: sabit bir de?er olmal?d?r {1} @@ -15,10 +16,10 @@ edits = {0}: ''d enum = {0}: {1} numaraland?rmas?nda bir de?er yok exclusiveMaximum = {0}: {1} gibi zel bir maksimum de?ere sahip olmal?d?r exclusiveMinimum = {0}: {1} gibi zel bir minimum de?ere sahip olmal?d?r -false = Boolean ?emas? false geerli de?il +false = {0}: Boolean ?emas? false geerli de?il format = {0}: {1} kal?b? {2} ile e?le?miyor id = {0}: {1}, {2} URI''si iin geersiz bir segmenttir -items = {0}[{1}]: bu dizinde do?rulay?c? bulunamad? +items = {0}: [{1}] bu dizinde do?rulay?c? bulunamad? maxContains = {0}: {1} iinde negatif olmayan bir tamsay? olmal?d?r maxItems = {0}: dizide en fazla {1} ?e olmal?d?r maxLength = {0}: yaln?zca {1} karakter uzunlu?unda olabilir @@ -32,18 +33,18 @@ minProperties = {0}: en az {1} minimum = {0}: minimum de?er {1} olmal?d?r multipleOf = {0}: {1}''in kat? olmal?d?r not = {0}: {1} ?emas? iin geerli olmamal?d?r -notAllowed = {0}.{1}: izin verilmez, ancak verilerde bulunur +notAllowed = {0}: ''{1}'' izin verilmez, ancak verilerde bulunur oneOf = {0}: yaln?zca bir ve yaln?zca bir ?ema iin geerli olmal?d?r, ancak {1} geerlidir pattern = {0}: normal ifade kal?b? {1} ile e?le?miyor patternProperties = {0}: ''kal?p zelliklerinde'' baz? hatalar var -prefixItems = {0}[{1}]: bu dizinde do?rulay?c? bulunamad? +prefixItems = {0}: [{1}] bu dizinde do?rulay?c? bulunamad? properties = {0}: ''zellikler'' ile ilgili bir hata var -propertyNames = Mlk ad? {0} do?rulama iin geerli de?il: {1} +propertyNames = {0}: ''{1}'' Mlk ad? {0} do?rulama iin geerli de?il: {1} readOnly = {0}: salt okunur bir aland?r, de?i?tirilemez -required = {0}.{1}: eksik ama gerekli +required = {0}: ''{1}'' eksik ama gerekli type = {0}: {1} bulundu, {2} bekleniyor -unevaluatedItems = A?a??daki yollarda de?erlendirilmemi? ?eler var {0} -unevaluatedProperties = A?a??daki yollarda de?erlendirilmemi? zellikler var {0} +unevaluatedItems = {0}: ''{1}'' A?a??daki yollarda de?erlendirilmemi? ?eler var {0} +unevaluatedProperties = {0}: ''{1}'' A?a??daki yollarda de?erlendirilmemi? zellikler var {0} unionType = {0}: {1} bulundu, ancak {2} gerekli uniqueItems = {0}: dizideki ?eler benzersiz olmal?d?r uuid = {0}: {1} geersiz bir {2} diff --git a/src/main/resources/jsv-messages_uk_UA.properties b/src/main/resources/jsv-messages_uk_UA.properties index 22c22c814..a12cde690 100644 --- a/src/main/resources/jsv-messages_uk_UA.properties +++ b/src/main/resources/jsv-messages_uk_UA.properties @@ -1,5 +1,6 @@ ref = {0}: містить помилку з ''refs'' -additionalProperties = {0}.{1}: не визначено в схемі, і схема не дозволяє додаткові властивості +additionalItems = {0}: [{1}] за цим індексом не знайдено валідатора +additionalProperties = {0}: ''{1}'' не визначено в схемі, і схема не дозволяє додаткові властивості allOf = {0}: має бути дійсним для всіх схем {1} anyOf = {0}: має бути дійсним для будь-якої зі схем {1} const = {0}: має бути постійним значенням {1} @@ -18,7 +19,7 @@ exclusiveMinimum = {0}: повинно мати виняткове мініма false = логічна схема false недійсна format = {0}: не відповідає шаблону {1} ​​{2} id = {0}: {1} є недійсним сегментом для URI {2} -items = {0}[{1}]: за цим індексом не знайдено валідатора +items = {0}: [{1}] за цим індексом не знайдено валідатора maxContains = {0}: має бути невід’ємним цілим числом у {1} maxItems = {0}: у масиві має бути максимум {1} елементів maxLength = {0}: може містити лише {1} символів @@ -32,18 +33,18 @@ minProperties = {0}: має мати мінімум {1} властивостей minimum = {0}: має мати мінімальне значення {1} multipleOf = {0}: має бути кратним {1} not = {0}: не має бути дійсним для схеми {1} -notAllowed = {0}.{1}: заборонено, але воно є в даних +notAllowed = {0}: ''{1}'' заборонено, але воно є в даних oneOf = {0}: має бути дійсним для однієї й лише однієї схеми, але {1} є дійсними pattern = {0}: не відповідає шаблону регулярного виразу {1} patternProperties = {0}: є деяка помилка з "властивостями шаблону" -prefixItems = {0}[{1}]: за цим індексом не знайдено валідатора +prefixItems = {0}: [{1}] за цим індексом не знайдено валідатора properties = {0}: містить помилку з "властивостями" -propertyNames = Назва властивості {0} недійсна для перевірки: {1} +propertyNames = {0}: ''{1}'' Назва властивості {0} недійсна для перевірки: {1} readOnly = {0}: це поле лише для читання, його не можна змінити -required = {0}.{1}: відсутній, але обов’язковий +required = {0}: ''{1}'' відсутній, але обов’язковий type = {0}: знайдено {1}, очікується {2} -unevaluatedItems = Є неоцінені елементи на таких шляхах {0} -unevaluatedProperties = Є неоцінені властивості на наступних шляхах {0} +unevaluatedItems = {0}: ''{1}'' Є неоцінені елементи на таких шляхах {0} +unevaluatedProperties = {0}: ''{1}'' Є неоцінені властивості на наступних шляхах {0} unionType = {0}: знайдено {1}, але потрібно {2} uniqueItems = {0}: елементи в масиві мають бути унікальними uuid = {0}: {1} є недійсним {2} diff --git a/src/main/resources/jsv-messages_vi_VN.properties b/src/main/resources/jsv-messages_vi_VN.properties index 81fa75368..4922fb425 100644 --- a/src/main/resources/jsv-messages_vi_VN.properties +++ b/src/main/resources/jsv-messages_vi_VN.properties @@ -1,5 +1,6 @@ $ref = {0}: c l?i v?i ''refs'' -additionalProperties = {0}.{1}: khng ???c xc ??nh trong l??c ?? v l??c ?? khng cho php cc thu?c tnh b? sung +additionalItems = {0}: [{1}] khng tm th?y trnh xc th?c no t?i ch? m?c ny +additionalProperties = {0}: ''{1}'' khng ???c xc ??nh trong l??c ?? v l??c ?? khng cho php cc thu?c tnh b? sung allOf = {0}: ph?i h?p l? v?i t?t c? cc l??c ?? {1} anyOf = {0}: ph?i h?p l? v?i b?t k? l??c ?? no {1} const = {0}: ph?i l m?t gi tr? khng ??i {1} @@ -15,10 +16,10 @@ edits = {0}: c enum = {0}: khng c gi tr? trong ki?u li?t k {1} exclusiveMaximum = {0}: ph?i c gi tr? t?i ?a ??c quy?n l {1} exclusiveMinimum = {0}: ph?i c gi tr? t?i thi?u ??c quy?n l {1} -false = L??c ?? Boolean false khng h?p l? +false = {0}: L??c ?? Boolean false khng h?p l? format = {0}: khng kh?p v?i m?u {1} {2} id = {0}: {1} l phn ?o?n khng h?p l? cho URI {2} -items = {0}[{1}]: khng tm th?y trnh xc th?c no t?i ch? m?c ny +items = {0}: [{1}] khng tm th?y trnh xc th?c no t?i ch? m?c ny maxContains = {0}: ph?i l s? nguyn khng m trong {1} maxItems = {0}: ph?i c t?i ?a {1} m?c trong m?ng maxLength = {0}: ch? c th? di {1} k t? @@ -32,18 +33,18 @@ minProperties = {0}: ph?i c minimum = {0}: ph?i c gi tr? t?i thi?u l {1} multipleOf = {0}: ph?i l b?i s? c?a {1} not = {0}: khng h?p l? v?i l??c ?? {1} -notAllowed = {0}.{1}: khng ???c php nh?ng c trong d? li?u +notAllowed = {0}: ''{1}'' khng ???c php nh?ng c trong d? li?u oneOf = {0}: ph?i h?p l? v?i m?t v ch? m?t l??c ??, nh?ng {1} h?p l? pattern = {0}: khng kh?p v?i m?u bi?u th?c chnh quy {1} patternProperties = {0}: c m?t s? l?i v?i ''thu?c tnh m?u'' -prefixItems = {0}[{1}]: khng tm th?y trnh xc th?c no t?i ch? m?c ny +prefixItems = {0}: [{1}] khng tm th?y trnh xc th?c no t?i ch? m?c ny properties = {0}: c l?i v?i ''thu?c tnh'' -propertyNames = Tn thu?c tnh {0} khng h?p l? ?? xc th?c: {1} +propertyNames = {0}: ''{1}'' Tn thu?c tnh {0} khng h?p l? ?? xc th?c: {1} readOnly = {0}: l tr??ng ch? ??c, khng thay ??i ???c -required = {0}.{1}: b? thi?u nh?ng b?t bu?c +required = {0}: ''{1}'' b? thi?u nh?ng b?t bu?c type = {0}: tm th?y {1}, mong ??i {2} -unevaluatedItems = C cc m?c ch?a ???c ?nh gi t?i cc ???ng d?n sau {0} -unevaluatedProperties = C cc thu?c tnh ch?a ???c ?nh gi t?i cc ???ng d?n sau {0} +unevaluatedItems = {0}: ''{1}'' C cc m?c ch?a ???c ?nh gi t?i cc ???ng d?n sau {0} +unevaluatedProperties = {0}: ''{1}'' C cc thu?c tnh ch?a ???c ?nh gi t?i cc ???ng d?n sau {0} unionType = {0}: tm th?y {1}, nh?ng b?t bu?c ph?i c {2} uniqueItems = {0}: cc m?c trong m?ng ph?i l duy nh?t uuid = {0}: {1} l {2} khng h?p l? diff --git a/src/main/resources/jsv-messages_zh_CN.properties b/src/main/resources/jsv-messages_zh_CN.properties index ae4286c61..43ae262e4 100644 --- a/src/main/resources/jsv-messages_zh_CN.properties +++ b/src/main/resources/jsv-messages_zh_CN.properties @@ -1,5 +1,6 @@ ref = {0}:“refs”有错误 -additionalProperties = {0}.{1}:未在架构中定义,且架构不允许附加属性 +additionalItems = {0}:[{1}] 在此索引中找不到验证器 +additionalProperties = {0}:''{1}'' 未在架构中定义,且架构不允许附加属性 allOf = {0}:应对所有架构 {1} 有效 anyOf = {0}:应对任何架构 {1} 有效 const = {0}:必须是常量值 {1} @@ -15,7 +16,7 @@ edits = {0}:“edits”有错误 enum = {0}:枚举 {1} 中没有值 exclusiveMaximum = {0}:必须具有独占最大值 {1} exclusiveMinimum = {0}:必须具有独占最小值 {1} -false = 布尔模式 false 无效 +false = {0}: 布尔模式 false 无效 format = {0}:与 {1} 模式 {2} 不匹配 id = {0}:{1} 是 URI {2} 的无效段 items = {0}[{1}]:在此索引中找不到验证器 @@ -32,18 +33,18 @@ minProperties = {0}:至少应具有 {1} 个属性 minimum = {0}:最小值必须为 {1} multipleOf = {0}:必须是 {1} 的倍数 not = {0}:对于架构 {1} 不应有效 -notAllowed = {0}.{1}:不允许,但在数据中 +notAllowed = {0}:''{1}'' 不允许,但在数据中 oneOf = {0}:应该对一个且仅一个架构有效,但 {1} 有效 pattern = {0}:与正则表达式模式 {1} 不匹配 patternProperties = {0}:“模式属性”有一些错误 -prefixItems = {0}[{1}]:在此索引处找不到验证器 +prefixItems = {0}:[{1}] 在此索引处找不到验证器 properties = {0}:“属性”有错误 -propertyNames = 属性名称 {0} 对于验证无效:{1} +propertyNames = {0}:''{1}'' 属性名称 {0} 对于验证无效:{1} readOnly = {0}:是只读字段,无法更改 -required = {0}.{1}:缺少但必需 +required = {0}:''{1}'' 缺少但必需 type = {0}:已找到 {1},预计为 {2} -unevaluatedItems = 以下路径中有未评估的项目 {0} -unevaluatedProperties = 以下路径中有未评估的属性 {0} +unevaluatedItems = {0}:''{1}''以下路径中有未评估的项目 {0} +unevaluatedProperties = {0}:''{1}''以下路径中有未评估的属性 {0} unionType = {0}:已找到 {1},但需要 {2} uniqueItems = {0}:数组中的项目必须是唯一的 uuid = {0}:{1} 是无效的 {2} diff --git a/src/main/resources/jsv-messages_zh_TW.properties b/src/main/resources/jsv-messages_zh_TW.properties index 230d0e851..2109af275 100644 --- a/src/main/resources/jsv-messages_zh_TW.properties +++ b/src/main/resources/jsv-messages_zh_TW.properties @@ -1,5 +1,6 @@ $ref = {0}:“refs”有錯誤 -additionalProperties = {0}.{1}:未在架構中定義,且架構不允許附加屬性 +additionalItems = {0}:[{1}] 在此索引中找不到驗證器 +additionalProperties = {0}:''{1}'' 未在架構中定義,且架構不允許附加屬性 allOf = {0}:應對所有架構 {1} 有效 anyOf = {0}:應對任何架構 {1} 有效 const = {0}:必須是常量值 {1} @@ -18,7 +19,7 @@ exclusiveMinimum = {0}:必須具有獨占最小值 {1} false = 布爾模式 false 無效 format = {0}:與 {1} 模式 {2} 不匹配 id = {0}:{1} 是 URI {2} 的無效段 -items = {0}[{1}]:在此索引中找不到驗證器 +items = {0}:[{1}] 在此索引中找不到驗證器 maxContains = {0}:必須是 {1} 中的非負整數 maxItems = {0}:數組中最多必須有 {1} 個項目 maxLength = {0}:只能是 {1} 個字符長 @@ -32,18 +33,18 @@ minProperties = {0}:至少應具有 {1} 個屬性 minimum = {0}:最小值必須為 {1} multipleOf = {0}:必須是 {1} 的倍數 not = {0}:對於架構 {1} 不應有效 -notAllowed = {0}.{1}:不允許,但在數據中 +notAllowed = {0}:''{1}'' 不允許,但在數據中 oneOf = {0}:應該對一個且僅一個架構有效,但 {1} 有效 pattern = {0}:與正則表達式模式 {1} 不匹配 patternProperties = {0}:“模式屬性”有一些錯誤 -prefixItems = {0}[{1}]:在此索引處找不到驗證器 +prefixItems = {0}:[{1}] 在此索引處找不到驗證器 properties = {0}:“屬性”有錯誤 -propertyNames = 屬性名稱 {0} 對於驗證無效:{1} +propertyNames = {0}:''{1}'' 屬性名稱 {0} 對於驗證無效:{1} readOnly = {0}:是只讀字段,無法更改 -required = {0}.{1}:缺少但必需 +required = {0}:''{1}'' 缺少但必需 type = {0}:已找到 {1},預計為 {2} -unevaluatedItems = 以下路徑中有未評估的項目 {0} -unevaluatedProperties = 以下路徑中有未評估的屬性 {0} +unevaluatedItems = {0}:''{1}'' 以下路徑中有未評估的項目 {0} +unevaluatedProperties = {0}:''{1}'' 以下路徑中有未評估的屬性 {0} unionType = {0}:已找到 {1},但需要 {2} uniqueItems = {0}:數組中的項目必須是唯一的 uuid = {0}:{1} 是無效的 {2} diff --git a/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java new file mode 100644 index 000000000..c133d83af --- /dev/null +++ b/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.networknt.schema; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; + +import java.util.Set; + +import org.junit.jupiter.api.Test; + +import com.networknt.schema.SpecVersion.VersionFlag; + +/** + * AdditionalPropertiesValidatorTest. + */ +public class AdditionalPropertiesValidatorTest { + /** + * Tests that the message contains the correct values when additional properties + * schema is false. + */ + @Test + void messageFalse() { + String schemaData = "{\r\n" + + " \"$id\": \"https://www.example.org/schema\",\r\n" + + " \"type\": \"object\",\r\n" + + " \"properties\": {\r\n" + + " \"foo\": {\r\n" + + " \"type\": \"string\"\r\n" + + " }\r\n" + + " },\r\n" + + " \"additionalProperties\": false\r\n" + + "}"; + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + SchemaValidatorsConfig config = new SchemaValidatorsConfig(); + config.setPathType(PathType.JSON_POINTER); + JsonSchema schema = factory.getSchema(schemaData, config); + String inputData = "{\r\n" + + " \"foo\":\"hello\",\r\n" + + " \"bar\":\"world\"\r\n" + + "}"; + Set messages = schema.validate(inputData, InputFormat.JSON); + assertFalse(messages.isEmpty()); + ValidationMessage message = messages.iterator().next(); + assertEquals("/additionalProperties", message.getEvaluationPath().toString()); + assertEquals("https://www.example.org/schema#/additionalProperties", message.getSchemaLocation().toString()); + assertEquals("", message.getInstanceLocation().toString()); + assertEquals("false", message.getSchemaNode().toString()); + assertEquals("{\"foo\":\"hello\",\"bar\":\"world\"}", message.getInstanceNode().toString()); + assertEquals(": property 'bar' is not defined in the schema and the schema does not allow additional properties", message.getMessage()); + assertEquals("bar", message.getProperty()); + } + + /** + * Tests that the message contains the correct values when additional properties + * schema has a schema with type. + */ + @Test + void messageSchema() { + String schemaData = "{\r\n" + + " \"$id\": \"https://www.example.org/schema\",\r\n" + + " \"type\": \"object\",\r\n" + + " \"properties\": {\r\n" + + " \"foo\": {\r\n" + + " \"type\": \"string\"\r\n" + + " }\r\n" + + " },\r\n" + + " \"additionalProperties\": { \"type\": \"number\" }\r\n" + + "}"; + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + SchemaValidatorsConfig config = new SchemaValidatorsConfig(); + config.setPathType(PathType.JSON_POINTER); + JsonSchema schema = factory.getSchema(schemaData, config); + String inputData = "{\r\n" + + " \"foo\":\"hello\",\r\n" + + " \"bar\":\"world\"\r\n" + + "}"; + Set messages = schema.validate(inputData, InputFormat.JSON); + assertFalse(messages.isEmpty()); + ValidationMessage message = messages.iterator().next(); + assertEquals("/additionalProperties/type", message.getEvaluationPath().toString()); + assertEquals("https://www.example.org/schema#/additionalProperties/type", message.getSchemaLocation().toString()); + assertEquals("/bar", message.getInstanceLocation().toString()); + assertEquals("\"number\"", message.getSchemaNode().toString()); + assertEquals("\"world\"", message.getInstanceNode().toString()); + assertEquals("/bar: string found, number expected", message.getMessage()); + assertNull(message.getProperty()); + } + +} diff --git a/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java b/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java index c001c628d..5650cd43d 100644 --- a/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java +++ b/src/test/java/com/networknt/schema/BaseJsonSchemaValidatorTest.java @@ -58,6 +58,9 @@ public static JsonSchema getJsonSchemaFromClasspath(String name, SpecVersion.Ver JsonSchemaFactory factory = JsonSchemaFactory.getInstance(schemaVersion); InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream(name); + if (config == null) { + return factory.getSchema(is); + } return factory.getSchema(is, config); } diff --git a/src/test/java/com/networknt/schema/Issue342Test.java b/src/test/java/com/networknt/schema/Issue342Test.java index 13f5b08bb..b6f4419a5 100644 --- a/src/test/java/com/networknt/schema/Issue342Test.java +++ b/src/test/java/com/networknt/schema/Issue342Test.java @@ -32,7 +32,7 @@ public void propertyNameEnumShouldFailV7() throws Exception { Set errors = schema.validate(node); Assertions.assertEquals(1, errors.size()); final ValidationMessage error = errors.iterator().next(); - Assertions.assertEquals("$.z", error.getInstanceLocation().toString()); - Assertions.assertEquals("Property name $.z is not valid for validation: does not have a value in the enumeration [a, b, c]", error.getMessage()); + Assertions.assertEquals("$", error.getInstanceLocation().toString()); + Assertions.assertEquals("$: property 'z' name is not valid: does not have a value in the enumeration [a, b, c]", error.getMessage()); } } diff --git a/src/test/java/com/networknt/schema/Issue375Test.java b/src/test/java/com/networknt/schema/Issue375Test.java index 86ccd0a1c..51353394b 100644 --- a/src/test/java/com/networknt/schema/Issue375Test.java +++ b/src/test/java/com/networknt/schema/Issue375Test.java @@ -53,9 +53,9 @@ public void shouldFailAndShowValidationValuesWithError() throws Exception { } List expectedMessages = Arrays.asList( - "Property name $.fields.longName123 is not valid for validation: may only be 5 characters long", - "Property name $.fields.longName123 is not valid for validation: does not match the regex pattern ^[a-zA-Z]+$", - "Property name $.fields.a is not valid for validation: must be at least 3 characters long"); + "$.fields: property 'longName123' name is not valid: must be at most 5 characters long", + "$.fields: property 'longName123' name is not valid: does not match the regex pattern ^[a-zA-Z]+$", + "$.fields: property 'a' name is not valid: must be at least 3 characters long"); MatcherAssert.assertThat(errorMessages, Matchers.containsInAnyOrder(expectedMessages.toArray())); } } diff --git a/src/test/java/com/networknt/schema/Issue396Test.java b/src/test/java/com/networknt/schema/Issue396Test.java index 54b8f5dd1..81a4c08aa 100644 --- a/src/test/java/com/networknt/schema/Issue396Test.java +++ b/src/test/java/com/networknt/schema/Issue396Test.java @@ -35,11 +35,11 @@ public void testComplexPropertyNamesV7() throws Exception { final Set expected = new HashSet<>(); node.fields().forEachRemaining(entry -> { if (!entry.getValue().asBoolean()) - expected.add("$." + entry.getKey()); + expected.add(entry.getKey()); }); Set errors = schema.validate(node); - final Set actual = errors.stream().map(ValidationMessage::getInstanceLocation).map(Object::toString).collect(Collectors.toSet()); + final Set actual = errors.stream().map(ValidationMessage::getProperty).map(Object::toString).collect(Collectors.toSet()); Assertions.assertEquals(expected, actual); } } diff --git a/src/test/java/com/networknt/schema/Issue493Test.java b/src/test/java/com/networknt/schema/Issue493Test.java index 07ba12bf1..c6e2f50ba 100644 --- a/src/test/java/com/networknt/schema/Issue493Test.java +++ b/src/test/java/com/networknt/schema/Issue493Test.java @@ -90,7 +90,7 @@ void testInvalidJson2 () assertThat(allErrorMessages, Matchers.containsInAnyOrder( "$.parameters[1].value: string found, integer expected", "$.parameters[1].value: does not match the regex pattern ^\\{\\{.+\\}\\}$", - "$.parameters[1]: should be valid to one and only one schema, but 0 are valid" + "$.parameters[1]: must be valid to one and only one schema, but 0 are valid" )); } } diff --git a/src/test/java/com/networknt/schema/Issue898Test.java b/src/test/java/com/networknt/schema/Issue898Test.java index 24b653c8e..c7107f066 100644 --- a/src/test/java/com/networknt/schema/Issue898Test.java +++ b/src/test/java/com/networknt/schema/Issue898Test.java @@ -25,7 +25,7 @@ void testMessagesWithSingleQuotes() throws Exception { Assertions.assertEquals(2, messages.size()); Assertions.assertEquals("$.foo: n'a pas de valeur dans l'énumération [foo1, foo2]", messages.get(0)); - Assertions.assertEquals("$.bar ne correspond pas à l'expression régulière (bar)+", messages.get(1)); + Assertions.assertEquals("$.bar: ne correspond pas à l'expression régulière (bar)+", messages.get(1)); } } diff --git a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java new file mode 100644 index 000000000..401e18218 --- /dev/null +++ b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.networknt.schema; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; + +import java.util.Set; + +import org.junit.jupiter.api.Test; + +import com.networknt.schema.SpecVersion.VersionFlag; + +/** + * ItemsValidatorTest. + */ +public class ItemsValidator202012Test { + /** + * Tests that the message contains the correct values when there are invalid + * items. + */ + @Test + void messageInvalid() { + String schemaData = "{\r\n" + + " \"$id\": \"https://www.example.org/schema\",\r\n" + + " \"items\": {\"type\": \"integer\"}" + + "}"; + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + SchemaValidatorsConfig config = new SchemaValidatorsConfig(); + config.setPathType(PathType.JSON_POINTER); + JsonSchema schema = factory.getSchema(schemaData, config); + String inputData = "[1, \"x\"]"; + Set messages = schema.validate(inputData, InputFormat.JSON); + assertFalse(messages.isEmpty()); + ValidationMessage message = messages.iterator().next(); + assertEquals("/items/type", message.getEvaluationPath().toString()); + assertEquals("https://www.example.org/schema#/items/type", message.getSchemaLocation().toString()); + assertEquals("/1", message.getInstanceLocation().toString()); + assertEquals("\"integer\"", message.getSchemaNode().toString()); + assertEquals("\"x\"", message.getInstanceNode().toString()); + assertEquals("/1: string found, integer expected", message.getMessage()); + assertNull(message.getProperty()); + } +} diff --git a/src/test/java/com/networknt/schema/ItemsValidatorTest.java b/src/test/java/com/networknt/schema/ItemsValidatorTest.java new file mode 100644 index 000000000..8823028b7 --- /dev/null +++ b/src/test/java/com/networknt/schema/ItemsValidatorTest.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.networknt.schema; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; + +import java.util.Set; + +import org.junit.jupiter.api.Test; + +import com.networknt.schema.SpecVersion.VersionFlag; + +/** + * ItemsValidatorTest. + */ +public class ItemsValidatorTest { + /** + * Tests that the message contains the correct values when there are invalid + * items. + */ + @Test + void messageInvalid() { + String schemaData = "{\r\n" + + " \"$id\": \"https://www.example.org/schema\",\r\n" + + " \"items\": {\"type\": \"integer\"}" + + "}"; + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V201909); + SchemaValidatorsConfig config = new SchemaValidatorsConfig(); + config.setPathType(PathType.JSON_POINTER); + JsonSchema schema = factory.getSchema(schemaData, config); + String inputData = "[1, \"x\"]"; + Set messages = schema.validate(inputData, InputFormat.JSON); + assertFalse(messages.isEmpty()); + ValidationMessage message = messages.iterator().next(); + assertEquals("/items/type", message.getEvaluationPath().toString()); + assertEquals("https://www.example.org/schema#/items/type", message.getSchemaLocation().toString()); + assertEquals("/1", message.getInstanceLocation().toString()); + assertEquals("\"integer\"", message.getSchemaNode().toString()); + assertEquals("\"x\"", message.getInstanceNode().toString()); + assertEquals("/1: string found, integer expected", message.getMessage()); + assertNull(message.getProperty()); + } + + /** + * Tests that the message contains the correct values when there are invalid + * items. + */ + @Test + void messageAdditionalItemsInvalid() { + String schemaData = "{\r\n" + + " \"$id\": \"https://www.example.org/schema\",\r\n" + + " \"items\": [{}]," + + " \"additionalItems\": {\"type\": \"integer\"}" + + "}"; + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V201909); + SchemaValidatorsConfig config = new SchemaValidatorsConfig(); + config.setPathType(PathType.JSON_POINTER); + JsonSchema schema = factory.getSchema(schemaData, config); + String inputData = "[ null, 2, 3, \"foo\" ]"; + Set messages = schema.validate(inputData, InputFormat.JSON); + assertFalse(messages.isEmpty()); + ValidationMessage message = messages.iterator().next(); + assertEquals("/additionalItems/type", message.getEvaluationPath().toString()); + assertEquals("https://www.example.org/schema#/additionalItems/type", message.getSchemaLocation().toString()); + assertEquals("/3", message.getInstanceLocation().toString()); + assertEquals("\"integer\"", message.getSchemaNode().toString()); + assertEquals("\"foo\"", message.getInstanceNode().toString()); + assertEquals("/3: string found, integer expected", message.getMessage()); + assertNull(message.getProperty()); + } + + /** + * Tests that the message contains the correct values when there are invalid + * items. + */ + @Test + void messageAdditionalItemsFalseInvalid() { + String schemaData = "{\r\n" + + " \"$id\": \"https://www.example.org/schema\",\r\n" + + " \"items\": [{}]," + + " \"additionalItems\": false" + + "}"; + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V201909); + SchemaValidatorsConfig config = new SchemaValidatorsConfig(); + config.setPathType(PathType.JSON_POINTER); + JsonSchema schema = factory.getSchema(schemaData, config); + String inputData = "[ null, 2, 3, \"foo\" ]"; + Set messages = schema.validate(inputData, InputFormat.JSON); + assertFalse(messages.isEmpty()); + ValidationMessage message = messages.iterator().next(); + assertEquals("/additionalItems", message.getEvaluationPath().toString()); + assertEquals("https://www.example.org/schema#/additionalItems", message.getSchemaLocation().toString()); + assertEquals("", message.getInstanceLocation().toString()); + assertEquals("false", message.getSchemaNode().toString()); + assertEquals("[null,2,3,\"foo\"]", message.getInstanceNode().toString()); + assertEquals(": index '1' is not defined in the schema and the schema does not allow additional items", message.getMessage()); + assertNull(message.getProperty()); + } +} diff --git a/src/test/java/com/networknt/schema/OutputFormatTest.java b/src/test/java/com/networknt/schema/OutputFormatTest.java index dc6ef6c07..bc25acb34 100644 --- a/src/test/java/com/networknt/schema/OutputFormatTest.java +++ b/src/test/java/com/networknt/schema/OutputFormatTest.java @@ -43,8 +43,8 @@ void testInvalidJson() throws Exception { assertThat(messages, Matchers.containsInAnyOrder( new String[] { "/minItems", "https://example.com/polygon#/minItems", "", ": expected at least 3 items but found 2" }, - new String[] { "/items/$ref/additionalProperties", "https://example.com/polygon#/$defs/point/additionalProperties", "/1/z", - "/1/z: is not defined in the schema and the schema does not allow additional properties" }, + new String[] { "/items/$ref/additionalProperties", "https://example.com/polygon#/$defs/point/additionalProperties", "/1", + "/1: property 'z' is not defined in the schema and the schema does not allow additional properties" }, new String[] { "/items/$ref/required", "https://example.com/polygon#/$defs/point/required", "/1", "/1: required property 'y' not found"})); } } diff --git a/src/test/java/com/networknt/schema/OutputUnitTest.java b/src/test/java/com/networknt/schema/OutputUnitTest.java index 1d3b83c8a..42e10d851 100644 --- a/src/test/java/com/networknt/schema/OutputUnitTest.java +++ b/src/test/java/com/networknt/schema/OutputUnitTest.java @@ -106,7 +106,7 @@ void annotationCollectionList() throws JsonProcessingException { executionConfiguration.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); }); String output = JsonMapperFactory.getInstance().writeValueAsString(outputUnit); - String expected = "{\"valid\":false,\"details\":[{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/0\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/0\",\"instanceLocation\":\"/foo\",\"errors\":{\"required\":\"required property 'unspecified-prop' not found\"}},{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/1/properties/foo-prop\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/1/properties/foo-prop\",\"instanceLocation\":\"/foo/foo-prop\",\"errors\":{\"const\":\"must be a constant value 1\"},\"droppedAnnotations\":{\"title\":\"foo-prop-title\"}},{\"valid\":false,\"evaluationPath\":\"/properties/bar/$ref/properties/bar-prop\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/$defs/bar/properties/bar-prop\",\"instanceLocation\":\"/bar/bar-prop\",\"errors\":{\"minimum\":\"must have a minimum value of 10\"},\"droppedAnnotations\":{\"title\":\"bar-prop-title\"}},{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/1\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/1\",\"instanceLocation\":\"/foo\",\"droppedAnnotations\":{\"properties\":[\"foo-prop\"],\"title\":\"foo-title\",\"additionalProperties\":[\"foo-prop\",\"other-prop\"]}},{\"valid\":false,\"evaluationPath\":\"/properties/bar/$ref\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/$defs/bar\",\"instanceLocation\":\"/bar\",\"droppedAnnotations\":{\"properties\":[\"bar-prop\"],\"title\":\"bar-title\"}},{\"valid\":false,\"evaluationPath\":\"\",\"schemaLocation\":\"https://json-schema.org/schemas/example#\",\"instanceLocation\":\"\",\"droppedAnnotations\":{\"properties\":[\"foo\",\"bar\"],\"title\":\"root\"}}]}"; + String expected = "{\"valid\":false,\"details\":[{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/0\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/0\",\"instanceLocation\":\"/foo\",\"errors\":{\"required\":\"required property 'unspecified-prop' not found\"}},{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/1/properties/foo-prop\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/1/properties/foo-prop\",\"instanceLocation\":\"/foo/foo-prop\",\"errors\":{\"const\":\"must be the constant value 1\"},\"droppedAnnotations\":{\"title\":\"foo-prop-title\"}},{\"valid\":false,\"evaluationPath\":\"/properties/bar/$ref/properties/bar-prop\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/$defs/bar/properties/bar-prop\",\"instanceLocation\":\"/bar/bar-prop\",\"errors\":{\"minimum\":\"must have a minimum value of 10\"},\"droppedAnnotations\":{\"title\":\"bar-prop-title\"}},{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/1\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/1\",\"instanceLocation\":\"/foo\",\"droppedAnnotations\":{\"properties\":[\"foo-prop\"],\"title\":\"foo-title\",\"additionalProperties\":[\"foo-prop\",\"other-prop\"]}},{\"valid\":false,\"evaluationPath\":\"/properties/bar/$ref\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/$defs/bar\",\"instanceLocation\":\"/bar\",\"droppedAnnotations\":{\"properties\":[\"bar-prop\"],\"title\":\"bar-title\"}},{\"valid\":false,\"evaluationPath\":\"\",\"schemaLocation\":\"https://json-schema.org/schemas/example#\",\"instanceLocation\":\"\",\"droppedAnnotations\":{\"properties\":[\"foo\",\"bar\"],\"title\":\"root\"}}]}"; assertEquals(expected, output); } @@ -124,7 +124,7 @@ void annotationCollectionHierarchical() throws JsonProcessingException { executionConfiguration.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); }); String output = JsonMapperFactory.getInstance().writeValueAsString(outputUnit); - String expected = "{\"valid\":false,\"evaluationPath\":\"\",\"schemaLocation\":\"https://json-schema.org/schemas/example#\",\"instanceLocation\":\"\",\"droppedAnnotations\":{\"properties\":[\"foo\",\"bar\"],\"title\":\"root\"},\"details\":[{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/0\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/0\",\"instanceLocation\":\"/foo\",\"errors\":{\"required\":\"required property 'unspecified-prop' not found\"}},{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/1\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/1\",\"instanceLocation\":\"/foo\",\"droppedAnnotations\":{\"properties\":[\"foo-prop\"],\"title\":\"foo-title\",\"additionalProperties\":[\"foo-prop\",\"other-prop\"]},\"details\":[{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/1/properties/foo-prop\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/1/properties/foo-prop\",\"instanceLocation\":\"/foo/foo-prop\",\"errors\":{\"const\":\"must be a constant value 1\"},\"droppedAnnotations\":{\"title\":\"foo-prop-title\"}}]},{\"valid\":false,\"evaluationPath\":\"/properties/bar/$ref\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/$defs/bar\",\"instanceLocation\":\"/bar\",\"droppedAnnotations\":{\"properties\":[\"bar-prop\"],\"title\":\"bar-title\"},\"details\":[{\"valid\":false,\"evaluationPath\":\"/properties/bar/$ref/properties/bar-prop\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/$defs/bar/properties/bar-prop\",\"instanceLocation\":\"/bar/bar-prop\",\"errors\":{\"minimum\":\"must have a minimum value of 10\"},\"droppedAnnotations\":{\"title\":\"bar-prop-title\"}}]}]}"; + String expected = "{\"valid\":false,\"evaluationPath\":\"\",\"schemaLocation\":\"https://json-schema.org/schemas/example#\",\"instanceLocation\":\"\",\"droppedAnnotations\":{\"properties\":[\"foo\",\"bar\"],\"title\":\"root\"},\"details\":[{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/0\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/0\",\"instanceLocation\":\"/foo\",\"errors\":{\"required\":\"required property 'unspecified-prop' not found\"}},{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/1\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/1\",\"instanceLocation\":\"/foo\",\"droppedAnnotations\":{\"properties\":[\"foo-prop\"],\"title\":\"foo-title\",\"additionalProperties\":[\"foo-prop\",\"other-prop\"]},\"details\":[{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/1/properties/foo-prop\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/1/properties/foo-prop\",\"instanceLocation\":\"/foo/foo-prop\",\"errors\":{\"const\":\"must be the constant value 1\"},\"droppedAnnotations\":{\"title\":\"foo-prop-title\"}}]},{\"valid\":false,\"evaluationPath\":\"/properties/bar/$ref\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/$defs/bar\",\"instanceLocation\":\"/bar\",\"droppedAnnotations\":{\"properties\":[\"bar-prop\"],\"title\":\"bar-title\"},\"details\":[{\"valid\":false,\"evaluationPath\":\"/properties/bar/$ref/properties/bar-prop\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/$defs/bar/properties/bar-prop\",\"instanceLocation\":\"/bar/bar-prop\",\"errors\":{\"minimum\":\"must have a minimum value of 10\"},\"droppedAnnotations\":{\"title\":\"bar-prop-title\"}}]}]}"; assertEquals(expected, output); } @@ -291,4 +291,52 @@ void unevaluatedProperties() throws JsonProcessingException { assertEquals(expected, output); } + /** + * Test that anyOf doesn't short circuit if annotations are turned on. + * + * @see anyOf + * @throws JsonProcessingException the exception + */ + @Test + void anyOf() throws JsonProcessingException { + // Test that any of doesn't short circuit if annotations need to be collected + String schemaData = "{\r\n" + + " \"type\": \"object\",\r\n" + + " \"anyOf\": [\r\n" + + " {\r\n" + + " \"properties\": {\r\n" + + " \"foo\": {\r\n" + + " \"type\": \"string\"\r\n" + + " }\r\n" + + " }\r\n" + + " },\r\n" + + " {\r\n" + + " \"properties\": {\r\n" + + " \"bar\": {\r\n" + + " \"type\": \"integer\"\r\n" + + " }\r\n" + + " }\r\n" + + " }\r\n" + + " ]\r\n" + + "}"; + + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + SchemaValidatorsConfig config = new SchemaValidatorsConfig(); + config.setPathType(PathType.JSON_POINTER); + JsonSchema schema = factory.getSchema(schemaData, config); + + String inputData = "{\r\n" + + " \"foo\": \"hello\",\r\n" + + " \"bar\": 1\r\n" + + "}"; + OutputUnit outputUnit = schema.validate(inputData, InputFormat.JSON, OutputFormat.HIERARCHICAL, executionContext -> { + executionContext.getExecutionConfig().setAnnotationCollectionEnabled(true); + executionContext.getExecutionConfig().setAnnotationCollectionFilter(keyword -> true); + }); + String output = JsonMapperFactory.getInstance().writeValueAsString(outputUnit); + String expected = "{\"valid\":true,\"evaluationPath\":\"\",\"schemaLocation\":\"#\",\"instanceLocation\":\"\",\"details\":[{\"valid\":true,\"evaluationPath\":\"/anyOf/0\",\"schemaLocation\":\"#/anyOf/0\",\"instanceLocation\":\"\",\"annotations\":{\"properties\":[\"foo\"]}},{\"valid\":true,\"evaluationPath\":\"/anyOf/1\",\"schemaLocation\":\"#/anyOf/1\",\"instanceLocation\":\"\",\"annotations\":{\"properties\":[\"bar\"]}}]}"; + assertEquals(expected, output); + } + } diff --git a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java index 488d3b138..39e7eb511 100644 --- a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java @@ -17,9 +17,15 @@ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.SpecVersion.VersionFlag; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; + import java.util.Set; /** @@ -52,4 +58,57 @@ public void testInvalidPatternPropertiesValidatorECMA262() throws Exception { Assertions.assertEquals(errors.size(), 0); }); } + + @Test + void message() { + String schemaData = "{\n" + + " \"$id\": \"https://www.example.org/schema\",\n" + + " \"type\": \"object\",\n" + + " \"patternProperties\": {\n" + + " \"^valid_\": {\n" + + " \"type\": [\"array\", \"string\"],\n" + + " \"items\": {\n" + + " \"type\": \"string\"\n" + + " }\n" + + " }\n" + + " }\n" + + "}"; + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + SchemaValidatorsConfig config = new SchemaValidatorsConfig(); + config.setPathType(PathType.JSON_POINTER); + JsonSchema schema = factory.getSchema(schemaData, config); + String inputData = "{\n" + + " \"valid_array\": [\"array1_value\", \"array2_value\"],\n" + + " \"valid_string\": \"string_value\",\n" + + " \"valid_key\": 5\n" + + "}"; + Set messages = schema.validate(inputData, InputFormat.JSON); + assertFalse(messages.isEmpty()); + ValidationMessage message = messages.iterator().next(); + assertEquals("/patternProperties/^valid_/type", message.getEvaluationPath().toString()); + assertEquals("https://www.example.org/schema#/patternProperties/^valid_/type", message.getSchemaLocation().toString()); + assertEquals("/valid_key", message.getInstanceLocation().toString()); + assertEquals("[\"array\",\"string\"]", message.getSchemaNode().toString()); + assertEquals("5", message.getInstanceNode().toString()); + assertEquals("/valid_key: integer found, but [array, string] is required", message.getMessage()); + assertNull(message.getProperty()); + + String inputData2 = "{\n" + + " \"valid_array\": [999, 2],\n" + + " \"valid_string\": \"string_value\",\n" + + " \"valid_key\": 5\n" + + "}"; + messages = schema.validate(inputData2, InputFormat.JSON); + assertFalse(messages.isEmpty()); + message = messages.iterator().next(); + assertEquals("/patternProperties/^valid_/items/type", message.getEvaluationPath().toString()); + assertEquals("https://www.example.org/schema#/patternProperties/^valid_/items/type", message.getSchemaLocation().toString()); + assertEquals("/valid_array/0", message.getInstanceLocation().toString()); + assertEquals("\"string\"", message.getSchemaNode().toString()); + assertEquals("999", message.getInstanceNode().toString()); + assertEquals("/valid_array/0: integer found, string expected", message.getMessage()); + assertNull(message.getProperty()); + + + } } diff --git a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java index 66f350e0f..b57d822ca 100644 --- a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java @@ -4,9 +4,16 @@ import org.junit.jupiter.api.DynamicNode; import org.junit.jupiter.api.Test; +import com.networknt.schema.SpecVersion.VersionFlag; + +import java.util.Set; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * This class handles exception case for {@link PrefixItemsValidator} @@ -29,5 +36,77 @@ void testEmptyPrefixItemsException() { ); } + /** + * Tests that the message contains the correct values when there are invalid + * items. + */ + @Test + void messageInvalid() { + String schemaData = "{\r\n" + + " \"$id\": \"https://www.example.org/schema\",\r\n" + + " \"prefixItems\": [{\"type\": \"string\"},{\"type\": \"integer\"}]" + + "}"; + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + SchemaValidatorsConfig config = new SchemaValidatorsConfig(); + config.setPathType(PathType.JSON_POINTER); + JsonSchema schema = factory.getSchema(schemaData, config); + String inputData = "[1, \"x\"]"; + Set messages = schema.validate(inputData, InputFormat.JSON); + assertFalse(messages.isEmpty()); + ValidationMessage message = messages.iterator().next(); + assertEquals("/prefixItems/type", message.getEvaluationPath().toString()); + assertEquals("https://www.example.org/schema#/prefixItems/type", message.getSchemaLocation().toString()); + assertEquals("/0", message.getInstanceLocation().toString()); + assertEquals("\"string\"", message.getSchemaNode().toString()); + assertEquals("1", message.getInstanceNode().toString()); + assertEquals("/0: integer found, string expected", message.getMessage()); + assertNull(message.getProperty()); + } + + /** + * Tests that the message contains the correct values when there are invalid + * items. + */ + @Test + void messageValid() { + String schemaData = "{\r\n" + + " \"$id\": \"https://www.example.org/schema\",\r\n" + + " \"prefixItems\": [{\"type\": \"string\"},{\"type\": \"integer\"}]" + + "}"; + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + SchemaValidatorsConfig config = new SchemaValidatorsConfig(); + config.setPathType(PathType.JSON_POINTER); + JsonSchema schema = factory.getSchema(schemaData, config); + String inputData = "[\"x\", 1, 1]"; + Set messages = schema.validate(inputData, InputFormat.JSON); + assertTrue(messages.isEmpty()); + } + /** + * Tests that the message contains the correct values when there are invalid + * items. + */ + @Test + void messageInvalidAdditionalItems() { + String schemaData = "{\r\n" + + " \"$id\": \"https://www.example.org/schema\",\r\n" + + " \"prefixItems\": [{\"type\": \"string\"},{\"type\": \"integer\"}],\r\n" + + " \"items\": false" + + "}"; + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + SchemaValidatorsConfig config = new SchemaValidatorsConfig(); + config.setPathType(PathType.JSON_POINTER); + JsonSchema schema = factory.getSchema(schemaData, config); + String inputData = "[\"x\", 1, 1, 2]"; + Set messages = schema.validate(inputData, InputFormat.JSON); + assertFalse(messages.isEmpty()); + ValidationMessage message = messages.iterator().next(); + assertEquals("/items", message.getEvaluationPath().toString()); + assertEquals("https://www.example.org/schema#/items", message.getSchemaLocation().toString()); + assertEquals("", message.getInstanceLocation().toString()); + assertEquals("false", message.getSchemaNode().toString()); + assertEquals("[\"x\",1,1,2]", message.getInstanceNode().toString()); + assertEquals(": index '2' is not defined in the schema and the schema does not allow additional items", message.getMessage()); + assertNull(message.getProperty()); + } } diff --git a/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java b/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java new file mode 100644 index 000000000..9b81d4c04 --- /dev/null +++ b/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.networknt.schema; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + +import java.util.Set; + +import org.junit.jupiter.api.Test; + +import com.networknt.schema.SpecVersion.VersionFlag; + +/** + * PropertyNamesValidatorTest. + */ +public class PropertyNamesValidatorTest { + /** + * Tests that the message contains the correct values when there are invalid + * property names. + */ + @Test + void messageInvalid() { + String schemaData = "{\r\n" + + " \"$id\": \"https://www.example.org/schema\",\r\n" + + " \"propertyNames\": {\"maxLength\": 3}\r\n" + + "}"; + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); + SchemaValidatorsConfig config = new SchemaValidatorsConfig(); + config.setPathType(PathType.JSON_POINTER); + JsonSchema schema = factory.getSchema(schemaData, config); + String inputData = "{\r\n" + + " \"foo\": {},\r\n" + + " \"foobar\": {}\r\n" + + "}"; + Set messages = schema.validate(inputData, InputFormat.JSON); + assertFalse(messages.isEmpty()); + ValidationMessage message = messages.iterator().next(); + assertEquals("/propertyNames", message.getEvaluationPath().toString()); + assertEquals("https://www.example.org/schema#/propertyNames", message.getSchemaLocation().toString()); + assertEquals("", message.getInstanceLocation().toString()); + assertEquals("{\"maxLength\":3}", message.getSchemaNode().toString()); + assertEquals("{\"foo\":{},\"foobar\":{}}", message.getInstanceNode().toString()); + assertEquals(": property 'foobar' name is not valid: must be at most 3 characters long", message.getMessage()); + assertEquals("foobar", message.getProperty()); + } +} diff --git a/src/test/java/com/networknt/schema/i18n/ResourceBundleMessageSourceTest.java b/src/test/java/com/networknt/schema/i18n/ResourceBundleMessageSourceTest.java index 809df08dd..7b48d2059 100644 --- a/src/test/java/com/networknt/schema/i18n/ResourceBundleMessageSourceTest.java +++ b/src/test/java/com/networknt/schema/i18n/ResourceBundleMessageSourceTest.java @@ -64,7 +64,7 @@ void messageFrench() { @Test void messageMaxItems() { String message = messageSource.getMessage("maxItems", Locale.getDefault(), "item", 5); - assertEquals("item: there must be a maximum of 5 items in the array", message); + assertEquals("item: must have a maximum of 5 items in the array", message); } @Test @@ -78,6 +78,6 @@ void overrideMessage() { MessageSource messageSource = new ResourceBundleMessageSource("jsv-messages-override", "jsv-messages"); assertEquals("path: overridden message value", messageSource.getMessage("allOf", Locale.ROOT, "path", "value")); assertEquals("path: overridden message value", messageSource.getMessage("allOf", Locale.FRENCH, "path", "value")); - assertEquals("path: should be valid to any of the schemas value", messageSource.getMessage("anyOf", Locale.ROOT, "path", "value")); + assertEquals("path: must be valid to any of the schemas value", messageSource.getMessage("anyOf", Locale.ROOT, "path", "value")); } } diff --git a/src/test/resources/draft2019-09/invalid-min-max-contains.json b/src/test/resources/draft2019-09/invalid-min-max-contains.json index 011522104..5bb15f114 100644 --- a/src/test/resources/draft2019-09/invalid-min-max-contains.json +++ b/src/test/resources/draft2019-09/invalid-min-max-contains.json @@ -11,7 +11,7 @@ "data": [], "valid": false, "validationMessages": [ - "/minContains: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"minContains\":\"1\"}" + "$: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"minContains\":\"1\"}" ] } ] @@ -28,7 +28,7 @@ "data": [], "valid": false, "validationMessages": [ - "/minContains: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"minContains\":0.5}" + "$: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"minContains\":0.5}" ] } ] @@ -45,7 +45,7 @@ "data": [], "valid": false, "validationMessages": [ - "/minContains: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"minContains\":-1}" + "$: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"minContains\":-1}" ] } ] @@ -62,7 +62,7 @@ "data": [], "valid": false, "validationMessages": [ - "/maxContains: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"maxContains\":\"1\"}" + "$: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"maxContains\":\"1\"}" ] } ] @@ -79,7 +79,7 @@ "data": [], "valid": false, "validationMessages": [ - "/maxContains: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"maxContains\":0.5}" + "$: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"maxContains\":0.5}" ] } ] @@ -96,7 +96,7 @@ "data": [], "valid": false, "validationMessages": [ - "/maxContains: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"maxContains\":-1}" + "$: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"maxContains\":-1}" ] } ] @@ -114,8 +114,8 @@ "data": [], "valid": false, "validationMessages": [ - "/maxContains: minContains must less than or equal to maxContains in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"maxContains\":0,\"minContains\":1}", - "/minContains: minContains must less than or equal to maxContains in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"maxContains\":0,\"minContains\":1}" + "$: minContains must less than or equal to maxContains in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"maxContains\":0,\"minContains\":1}", + "$: minContains must less than or equal to maxContains in {\"$schema\":\"https://json-schema.org/draft/2019-09/schema\",\"maxContains\":0,\"minContains\":1}" ] } ] diff --git a/src/test/resources/draft2020-12/invalid-min-max-contains.json b/src/test/resources/draft2020-12/invalid-min-max-contains.json index c19bdec70..4a3ee68dd 100644 --- a/src/test/resources/draft2020-12/invalid-min-max-contains.json +++ b/src/test/resources/draft2020-12/invalid-min-max-contains.json @@ -11,7 +11,7 @@ "data": [], "valid": false, "validationMessages": [ - "/minContains: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"minContains\":\"1\"}" + "$: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"minContains\":\"1\"}" ] } ] @@ -28,7 +28,7 @@ "data": [], "valid": false, "validationMessages": [ - "/minContains: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"minContains\":0.5}" + "$: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"minContains\":0.5}" ] } ] @@ -45,7 +45,7 @@ "data": [], "valid": false, "validationMessages": [ - "/minContains: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"minContains\":-1}" + "$: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"minContains\":-1}" ] } ] @@ -62,7 +62,7 @@ "data": [], "valid": false, "validationMessages": [ - "/maxContains: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"maxContains\":\"1\"}" + "$: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"maxContains\":\"1\"}" ] } ] @@ -79,7 +79,7 @@ "data": [], "valid": false, "validationMessages": [ - "/maxContains: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"maxContains\":0.5}" + "$: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"maxContains\":0.5}" ] } ] @@ -96,7 +96,7 @@ "data": [], "valid": false, "validationMessages": [ - "/maxContains: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"maxContains\":-1}" + "$: must be a non-negative integer in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"maxContains\":-1}" ] } ] @@ -114,8 +114,8 @@ "data": [], "valid": false, "validationMessages": [ - "/maxContains: minContains must less than or equal to maxContains in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"maxContains\":0,\"minContains\":1}", - "/minContains: minContains must less than or equal to maxContains in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"maxContains\":0,\"minContains\":1}" + "$: minContains must less than or equal to maxContains in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"maxContains\":0,\"minContains\":1}", + "$: minContains must less than or equal to maxContains in {\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"maxContains\":0,\"minContains\":1}" ] } ] diff --git a/src/test/resources/draft2020-12/issue656.json b/src/test/resources/draft2020-12/issue656.json index 65fd78294..53c468ff5 100644 --- a/src/test/resources/draft2020-12/issue656.json +++ b/src/test/resources/draft2020-12/issue656.json @@ -155,7 +155,7 @@ }, "valid": false, "validationMessages": [ - "$: should be valid to one and only one schema, but 2 are valid" + "$: must be valid to one and only one schema, but 2 are valid" ] } ] diff --git a/src/test/resources/draft4/issue425.json b/src/test/resources/draft4/issue425.json index ec205db5a..70e18fea5 100644 --- a/src/test/resources/draft4/issue425.json +++ b/src/test/resources/draft4/issue425.json @@ -35,7 +35,7 @@ }, "valid": false, "validationMessages": [ - "$.values: should be valid to one and only one schema, but 0 are valid", + "$.values: must be valid to one and only one schema, but 0 are valid", "$.values: integer found, array expected", "$.values: integer found, string expected" ] diff --git a/src/test/resources/draft7/issue470.json b/src/test/resources/draft7/issue470.json index 09aad528e..8dbbfa6d8 100644 --- a/src/test/resources/draft7/issue470.json +++ b/src/test/resources/draft7/issue470.json @@ -84,8 +84,8 @@ }, "valid": false, "validationMessages": [ - "$.search: should be valid to one and only one schema, but 0 are valid", - "$.search.byName: is not defined in the schema and the schema does not allow additional properties", + "$.search: must be valid to one and only one schema, but 0 are valid", + "$.search: property 'byName' is not defined in the schema and the schema does not allow additional properties", "$.search.byName.name: integer found, string expected" ] }, @@ -100,9 +100,9 @@ }, "valid": false, "validationMessages": [ - "$.search: should be valid to one and only one schema, but 0 are valid", - "$.search.byName: is not defined in the schema and the schema does not allow additional properties", - "$.search.byName.name: may only be 20 characters long" + "$.search: must be valid to one and only one schema, but 0 are valid", + "$.search: property 'byName' is not defined in the schema and the schema does not allow additional properties", + "$.search.byName.name: must be at most 20 characters long" ] }, { @@ -116,9 +116,9 @@ }, "valid": false, "validationMessages": [ - "$.search: should be valid to one and only one schema, but 0 are valid", + "$.search: must be valid to one and only one schema, but 0 are valid", "$.search.byAge.age: string found, integer expected", - "$.search.byAge: is not defined in the schema and the schema does not allow additional properties" + "$.search: property 'byAge' is not defined in the schema and the schema does not allow additional properties" ] }, { @@ -132,9 +132,9 @@ }, "valid": false, "validationMessages": [ - "$.search: should be valid to one and only one schema, but 0 are valid", + "$.search: must be valid to one and only one schema, but 0 are valid", "$.search.byAge.age: must have a maximum value of 150", - "$.search.byAge: is not defined in the schema and the schema does not allow additional properties" + "$.search: property 'byAge' is not defined in the schema and the schema does not allow additional properties" ] } ] diff --git a/src/test/resources/draft7/issue491.json b/src/test/resources/draft7/issue491.json index afcdc0910..b18463dde 100644 --- a/src/test/resources/draft7/issue491.json +++ b/src/test/resources/draft7/issue491.json @@ -84,7 +84,7 @@ "validationMessages": [ "$.search: required property 'name' not found", "$.search.searchAge.age: string found, integer expected", - "$.search: should be valid to one and only one schema, but 0 are valid" + "$.search: must be valid to one and only one schema, but 0 are valid" ] }, { @@ -98,7 +98,7 @@ "validationMessages": [ "$.search.name: integer found, string expected", "$.search: required property 'searchAge' not found", - "$.search: should be valid to one and only one schema, but 0 are valid" + "$.search: must be valid to one and only one schema, but 0 are valid" ] } ] @@ -186,7 +186,7 @@ "validationMessages": [ "$.search: required property 'name' not found", "$.search.byAge.age: string found, integer expected", - "$.search: should be valid to one and only one schema, but 0 are valid" + "$.search: must be valid to one and only one schema, but 0 are valid" ] }, { @@ -200,7 +200,7 @@ "validationMessages": [ "$.search.name: integer found, string expected", "$.search: required property 'byAge' not found", - "$.search: should be valid to one and only one schema, but 0 are valid" + "$.search: must be valid to one and only one schema, but 0 are valid" ] } ] @@ -278,7 +278,7 @@ "validationMessages": [ "$.search: required property 'name' not found", "$.search.age: string found, integer expected", - "$.search: should be valid to one and only one schema, but 0 are valid" + "$.search: must be valid to one and only one schema, but 0 are valid" ] }, { @@ -292,7 +292,7 @@ "validationMessages": [ "$.search.name: integer found, string expected", "$.search: required property 'age' not found", - "$.search: should be valid to one and only one schema, but 0 are valid" + "$.search: must be valid to one and only one schema, but 0 are valid" ] }, { @@ -306,7 +306,7 @@ "validationMessages": [ "$.search: required property 'name' not found", "$.search.age: must have a maximum value of 150", - "$.search: should be valid to one and only one schema, but 0 are valid" + "$.search: must be valid to one and only one schema, but 0 are valid" ] }, { @@ -318,9 +318,9 @@ }, "valid": false, "validationMessages": [ - "$.search.name: may only be 20 characters long", + "$.search.name: must be at most 20 characters long", "$.search: required property 'age' not found", - "$.search: should be valid to one and only one schema, but 0 are valid" + "$.search: must be valid to one and only one schema, but 0 are valid" ] } ] diff --git a/src/test/resources/draft7/issue516.json b/src/test/resources/draft7/issue516.json index 11430471b..f7a9de4b3 100644 --- a/src/test/resources/draft7/issue516.json +++ b/src/test/resources/draft7/issue516.json @@ -119,23 +119,23 @@ }, "valid": false, "validationMessages": [ - "$.activities[0]: should be valid to one and only one schema, but 0 are valid", - "$.activities[0].age: is not defined in the schema and the schema does not allow additional properties", + "$.activities[0]: must be valid to one and only one schema, but 0 are valid", + "$.activities[0]: property 'age' is not defined in the schema and the schema does not allow additional properties", "$.activities[0]: required property 'chemicalCharacteristic' not found", - "$.activities[0].height: is not defined in the schema and the schema does not allow additional properties", + "$.activities[0]: property 'height' is not defined in the schema and the schema does not allow additional properties", "$.activities[0]: required property 'weight' not found", - "$.activities[1]: should be valid to one and only one schema, but 0 are valid", - "$.activities[1].chemicalCharacteristic: is not defined in the schema and the schema does not allow additional properties", + "$.activities[1]: must be valid to one and only one schema, but 0 are valid", + "$.activities[1]: property 'chemicalCharacteristic' is not defined in the schema and the schema does not allow additional properties", "$.activities[1]: required property 'height' not found", - "$.activities[1].toxic: is not defined in the schema and the schema does not allow additional properties", + "$.activities[1]: property 'toxic' is not defined in the schema and the schema does not allow additional properties", "$.activities[1]: required property 'weight' not found", - "$.activities[2]: should be valid to one and only one schema, but 0 are valid", - "$.activities[2].chemicalCharacteristic: is not defined in the schema and the schema does not allow additional properties", - "$.activities[2].chemicalCharacteristic: should be valid to one and only one schema, but 0 are valid", - "$.activities[2].chemicalCharacteristic.categoryName: is not defined in the schema and the schema does not allow additional properties", - "$.activities[2].chemicalCharacteristic.name: is not defined in the schema and the schema does not allow additional properties", + "$.activities[2]: must be valid to one and only one schema, but 0 are valid", + "$.activities[2]: property 'chemicalCharacteristic' is not defined in the schema and the schema does not allow additional properties", + "$.activities[2].chemicalCharacteristic: must be valid to one and only one schema, but 0 are valid", + "$.activities[2].chemicalCharacteristic: property 'categoryName' is not defined in the schema and the schema does not allow additional properties", + "$.activities[2].chemicalCharacteristic: property 'name' is not defined in the schema and the schema does not allow additional properties", "$.activities[2]: required property 'height' not found", - "$.activities[2].toxic: is not defined in the schema and the schema does not allow additional properties", + "$.activities[2]: property 'toxic' is not defined in the schema and the schema does not allow additional properties", "$.activities[2]: required property 'weight' not found" ] } diff --git a/src/test/resources/draft7/issue653.json b/src/test/resources/draft7/issue653.json index 1fe83d156..4ee9e29d5 100644 --- a/src/test/resources/draft7/issue653.json +++ b/src/test/resources/draft7/issue653.json @@ -80,9 +80,9 @@ }, "valid": false, "validationMessages": [ - "$.pets[0]: should be valid to one and only one schema, but 0 are valid", + "$.pets[0]: must be valid to one and only one schema, but 0 are valid", "$.pets[0]: required property 'age' not found", - "Boolean schema false is not valid" + "$.pets[0]: schema for 'else' is false" ] } ] diff --git a/src/test/resources/draft7/issue678.json b/src/test/resources/draft7/issue678.json index 30b0cfece..b220968bf 100644 --- a/src/test/resources/draft7/issue678.json +++ b/src/test/resources/draft7/issue678.json @@ -52,7 +52,7 @@ "$.outerObject.innerObject: object found, string expected", "$.outerObject.innerObject: required property 'value' not found", "$.outerObject.innerObject: required property 'unit' not found", - "$.outerObject.innerObject: should be valid to one and only one schema, but 0 are valid" + "$.outerObject.innerObject: must be valid to one and only one schema, but 0 are valid" ] } ] diff --git a/src/test/resources/schema/customMessageTests/custom-message-disabled-tests.json b/src/test/resources/schema/customMessageTests/custom-message-disabled-tests.json index 11a632b67..c6cb67372 100644 --- a/src/test/resources/schema/customMessageTests/custom-message-disabled-tests.json +++ b/src/test/resources/schema/customMessageTests/custom-message-disabled-tests.json @@ -85,7 +85,7 @@ }, "valid": false, "validationMessages": [ - "$.foo: there must be a maximum of 3 items in the array" + "$.foo: must have a maximum of 3 items in the array" ] }, { @@ -114,7 +114,7 @@ }, "valid": false, "validationMessages": [ - "$.foo: there must be a maximum of 3 items in the array", + "$.foo: must have a maximum of 3 items in the array", "$.foo[2]: string found, number expected", "$.bar: integer found, string expected" ]