validate-value
Advanced tools
Comparing version 7.2.1 to 7.3.0
@@ -24,8 +24,18 @@ "use strict"; | ||
let message = 'Validation failed'; | ||
if (error.keyword === 'required') { | ||
const missingPropertyName = error.params.missingProperty; | ||
message = `Missing required property: ${missingPropertyName}`; | ||
// Ajv treats missing required properties as errors on the object that should have the property, so the name of | ||
// the missing property is missing in the data path and must be appended. | ||
updatedPath += `${separator}${missingPropertyName}`; | ||
switch (error.keyword) { | ||
case 'required': { | ||
const missingPropertyName = error.params.missingProperty; | ||
message = `Missing required property: ${missingPropertyName}`; | ||
updatedPath += `${separator}${missingPropertyName}`; | ||
break; | ||
} | ||
case 'additionalProperties': { | ||
const additionalPropertyName = error.params.additionalProperty; | ||
message = `Unexpected additional property: ${additionalPropertyName}`; | ||
updatedPath += `${separator}${additionalPropertyName}`; | ||
break; | ||
} | ||
default: { | ||
// Intentionally left blank. | ||
} | ||
} | ||
@@ -32,0 +42,0 @@ throw new ValidationError_1.ValidationError(`${message} (at ${updatedPath}).`, error); |
@@ -0,1 +1,8 @@ | ||
# [7.3.0](https://github.com/thenativeweb/validate-value/compare/7.2.1...7.3.0) (2020-10-09) | ||
### Features | ||
* Add more error messages. ([#182](https://github.com/thenativeweb/validate-value/issues/182)) ([b7e6e1f](https://github.com/thenativeweb/validate-value/commit/b7e6e1f43aea1a0349c2791ea86db3a07bdde13a)) | ||
## [7.2.1](https://github.com/thenativeweb/validate-value/compare/7.2.0...7.2.1) (2020-10-08) | ||
@@ -2,0 +9,0 @@ |
@@ -34,10 +34,24 @@ import Ajv from 'ajv'; | ||
if (error.keyword === 'required') { | ||
const missingPropertyName = (error.params as Ajv.RequiredParams).missingProperty; | ||
switch (error.keyword) { | ||
case 'required': { | ||
const missingPropertyName = (error.params as Ajv.RequiredParams).missingProperty; | ||
message = `Missing required property: ${missingPropertyName}`; | ||
message = `Missing required property: ${missingPropertyName}`; | ||
updatedPath += `${separator}${missingPropertyName}`; | ||
// Ajv treats missing required properties as errors on the object that should have the property, so the name of | ||
// the missing property is missing in the data path and must be appended. | ||
updatedPath += `${separator}${missingPropertyName}`; | ||
break; | ||
} | ||
case 'additionalProperties': { | ||
const additionalPropertyName = (error.params as Ajv.AdditionalPropertiesParams).additionalProperty; | ||
message = `Unexpected additional property: ${additionalPropertyName}`; | ||
updatedPath += `${separator}${additionalPropertyName}`; | ||
break; | ||
} | ||
default: { | ||
// Intentionally left blank. | ||
} | ||
} | ||
@@ -44,0 +58,0 @@ |
{ | ||
"name": "validate-value", | ||
"version": "7.2.1", | ||
"version": "7.3.0", | ||
"description": "validate-value validates values against JSON schemas.", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11571
165