validate-value
Advanced tools
Comparing version 8.2.0 to 8.3.0
@@ -8,2 +8,3 @@ "use strict"; | ||
const ajv_1 = __importDefault(require("ajv")); | ||
const getByDataPath_1 = require("./getByDataPath"); | ||
const ValidationError_1 = require("./ValidationError"); | ||
@@ -23,2 +24,3 @@ const ajvInstance = new ajv_1.default(); | ||
const error = this.validateInternal.errors[0]; | ||
const failingValue = getByDataPath_1.getByDataPath({ object: value, dataPath: error.dataPath }); | ||
let updatedPath = `${valueName}${error.dataPath.replace(/\//gu, separator)}`; | ||
@@ -39,2 +41,8 @@ let message = 'Validation failed'; | ||
} | ||
case 'minLength': { | ||
const minPropertyLength = error.params.limit; | ||
const actualLength = failingValue.length; | ||
message = `String is too short (${actualLength} chars), minimum ${minPropertyLength}`; | ||
break; | ||
} | ||
default: { | ||
@@ -41,0 +49,0 @@ // Intentionally left blank. |
@@ -0,1 +1,8 @@ | ||
# [8.3.0](https://github.com/thenativeweb/validate-value/compare/8.2.0...8.3.0) (2020-11-13) | ||
### Features | ||
* Add custom error message for minlength validation errors. ([#212](https://github.com/thenativeweb/validate-value/issues/212)) ([b7639cd](https://github.com/thenativeweb/validate-value/commit/b7639cd37aa48b1464faf9a373ab8fc7a3849181)) | ||
# [8.2.0](https://github.com/thenativeweb/validate-value/compare/8.1.1...8.2.0) (2020-11-12) | ||
@@ -2,0 +9,0 @@ |
import Ajv from 'ajv'; | ||
import { getByDataPath } from './getByDataPath'; | ||
import { JSONSchema7 } from 'json-schema'; | ||
@@ -30,2 +31,3 @@ import { ValidationError } from './ValidationError'; | ||
const error = this.validateInternal.errors![0]; | ||
const failingValue = getByDataPath({ object: value, dataPath: error.dataPath }); | ||
@@ -54,2 +56,11 @@ let updatedPath = `${valueName}${error.dataPath.replace(/\//gu, separator)}`; | ||
case 'minLength': { | ||
const minPropertyLength = (error.params as Ajv.LimitParams).limit; | ||
const actualLength = failingValue.length; | ||
message = `String is too short (${actualLength} chars), minimum ${minPropertyLength}`; | ||
break; | ||
} | ||
default: { | ||
@@ -56,0 +67,0 @@ // Intentionally left blank. |
{ | ||
"name": "validate-value", | ||
"version": "8.2.0", | ||
"version": "8.3.0", | ||
"description": "validate-value validates values against JSON schemas.", | ||
@@ -31,3 +31,3 @@ "contributors": [ | ||
"assertthat": "5.2.5", | ||
"roboter": "11.5.7", | ||
"roboter": "11.5.8", | ||
"semantic-release-configuration": "1.0.25" | ||
@@ -34,0 +34,0 @@ }, |
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
19433
25
287