ajv-errors
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -205,3 +205,6 @@ "use strict"; | ||
gen.if(codegen_1.and(ajv_1._ `${err}.keyword !== ${keyword}`, ajv_1._ `!${err}.${used}`, ajv_1._ `${err}.dataPath.indexOf(${dataPath}) === 0`), () => { | ||
const childRegex = gen.scopeValue("pattern", { ref: /^\/([^/]*)(?:\/|$)/ }); | ||
const childRegex = gen.scopeValue("pattern", { | ||
ref: /^\/([^/]*)(?:\/|$)/, | ||
code: ajv_1._ `new RegExp("^\\\/([^/]*)(?:\\\/|$)")`, | ||
}); | ||
const matches = gen.const("emMatches", ajv_1._ `${childRegex}.exec(${err}.dataPath.slice(${dataPath}.length))`); | ||
@@ -208,0 +211,0 @@ const child = gen.const("emChild", ajv_1._ `${matches} && ${matches}[1].replace(/~1/g, "/").replace(/~0/g, "~")`); |
{ | ||
"name": "ajv-errors", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Custom error messages in JSON-Schema for Ajv validator", | ||
@@ -14,4 +14,4 @@ "main": "dist/index.js", | ||
"eslint": "eslint \"src/**/*.*s\" \"spec/**/*.*s\"", | ||
"prettier:write": "prettier --write \"./**/*.{md,json,ts,js}\"", | ||
"prettier:check": "prettier --list-different \"./**/*.{md,json,ts,js}\"", | ||
"prettier:write": "prettier --write \"./**/*.{json,ts,js}\"", | ||
"prettier:check": "prettier --list-different \"./**/*.{json,ts,js}\"", | ||
"test-spec": "jest \"spec/*.ts\"", | ||
@@ -51,6 +51,5 @@ "test-cov": "jest \"spec/*.ts\" --coverage", | ||
"eslint-config-prettier": "^7.0.0", | ||
"husky": "^4.3.0", | ||
"husky": "^5.1.3", | ||
"jest": "^26.6.3", | ||
"lint-staged": "^10.5.1", | ||
"pre-commit": "^1.2.2", | ||
"prettier": "^2.1.2", | ||
@@ -67,4 +66,4 @@ "ts-jest": "^26.4.4", | ||
"lint-staged": { | ||
"*.{md,json,yaml,js,ts}": "prettier --write" | ||
"*.{json,yaml,js,ts}": "prettier --write" | ||
} | ||
} |
@@ -288,8 +288,7 @@ # ajv-errors | ||
#### Referring to Field Names | ||
#### Using property names in error messages | ||
Field names can be referred to by using the relative `0#` JSON-pointer. | ||
Property names can be used in error messages with the relative JSON-pointer (e.g. `0#`). | ||
Example which prints additional properties that cause validation error: | ||
Example: | ||
```javascript | ||
@@ -296,0 +295,0 @@ const schema = { |
@@ -295,3 +295,6 @@ import type {Plugin, CodeKeywordDefinition, KeywordCxt, ErrorObject, Code} from "ajv" | ||
() => { | ||
const childRegex = gen.scopeValue("pattern", {ref: /^\/([^/]*)(?:\/|$)/}) | ||
const childRegex = gen.scopeValue("pattern", { | ||
ref: /^\/([^/]*)(?:\/|$)/, | ||
code: _`new RegExp("^\\\/([^/]*)(?:\\\/|$)")`, | ||
}) | ||
const matches = gen.const( | ||
@@ -298,0 +301,0 @@ "emMatches", |
Sorry, the diff of this file is not supported yet
53068
14
641
342