ajv-keywords
Advanced tools
Comparing version 5.0.0 to 5.1.0
import type { DefinitionOptions } from "./_types"; | ||
import type { SchemaObject, CodeGen, Name } from "ajv"; | ||
import type { SchemaObject, KeywordCxt, Name } from "ajv"; | ||
export declare function metaSchemaRef({ defaultMeta }?: DefinitionOptions): SchemaObject; | ||
export declare function usePattern(gen: CodeGen, pattern: string, flags?: string): Name; | ||
export declare function usePattern({ gen, it: { opts } }: KeywordCxt, pattern: string, flags?: string): Name; |
@@ -10,7 +10,8 @@ "use strict"; | ||
exports.metaSchemaRef = metaSchemaRef; | ||
function usePattern(gen, pattern, flags = "u") { | ||
function usePattern({ gen, it: { opts } }, pattern, flags = opts.unicodeRegExp ? "u" : "") { | ||
const rx = new RegExp(pattern, flags); | ||
return gen.scopeValue("pattern", { | ||
key: pattern, | ||
ref: new RegExp(pattern, flags), | ||
code: codegen_1._ `new RegExp(${pattern}, ${flags})`, | ||
key: rx.toString(), | ||
ref: rx, | ||
code: (0, codegen_1._) `new RegExp(${pattern}, ${flags})`, | ||
}); | ||
@@ -17,0 +18,0 @@ } |
@@ -7,5 +7,5 @@ "use strict"; | ||
const _required_1 = __importDefault(require("./_required")); | ||
const getDef = _required_1.default("anyRequired"); | ||
const getDef = (0, _required_1.default)("anyRequired"); | ||
exports.default = getDef; | ||
module.exports = getDef; | ||
//# sourceMappingURL=anyRequired.js.map |
@@ -18,3 +18,3 @@ "use strict"; | ||
propertyNames: { type: "string", format: "json-pointer" }, | ||
additionalProperties: _util_1.metaSchemaRef(opts), | ||
additionalProperties: (0, _util_1.metaSchemaRef)(opts), | ||
}, | ||
@@ -21,0 +21,0 @@ }; |
@@ -11,4 +11,4 @@ "use strict"; | ||
const { schema, data } = ctx; | ||
const props = schema.map((jp) => codegen_1._ `(${getData(jp)}) === undefined`); | ||
ctx.fail(codegen_1.or(...props)); | ||
const props = schema.map((jp) => (0, codegen_1._) `(${getData(jp)}) === undefined`); | ||
ctx.fail((0, codegen_1.or)(...props)); | ||
function getData(jsonPointer) { | ||
@@ -19,4 +19,4 @@ if (jsonPointer === "") | ||
let x = data; | ||
const xs = segments.map((s, i) => i ? (x = codegen_1._ `${x}${codegen_1.getProperty(unescapeJPSegment(s))}`) : x); | ||
return codegen_1.and(...xs); | ||
const xs = segments.map((s, i) => i ? (x = (0, codegen_1._) `${x}${(0, codegen_1.getProperty)(unescapeJPSegment(s))}`) : x); | ||
return (0, codegen_1.and)(...xs); | ||
} | ||
@@ -23,0 +23,0 @@ }, |
@@ -7,5 +7,5 @@ "use strict"; | ||
const _range_1 = __importDefault(require("./_range")); | ||
const getDef = _range_1.default("exclusiveRange"); | ||
const getDef = (0, _range_1.default)("exclusiveRange"); | ||
exports.default = getDef; | ||
module.exports = getDef; | ||
//# sourceMappingURL=exclusiveRange.js.map |
@@ -40,3 +40,3 @@ "use strict"; | ||
function ajvKeywords(opts) { | ||
return definitions.map((d) => d(opts)).concat(select_1.default(opts)); | ||
return definitions.map((d) => d(opts)).concat((0, select_1.default)(opts)); | ||
} | ||
@@ -43,0 +43,0 @@ exports.default = ajvKeywords; |
@@ -7,5 +7,5 @@ "use strict"; | ||
const _required_1 = __importDefault(require("./_required")); | ||
const getDef = _required_1.default("oneRequired"); | ||
const getDef = (0, _required_1.default)("oneRequired"); | ||
exports.default = getDef; | ||
module.exports = getDef; | ||
//# sourceMappingURL=oneRequired.js.map |
@@ -6,4 +6,4 @@ "use strict"; | ||
const error = { | ||
message: ({ params: { missingPattern } }) => codegen_1.str `should have property matching pattern '${missingPattern}'`, | ||
params: ({ params: { missingPattern } }) => codegen_1._ `{missingPattern: ${missingPattern}}`, | ||
message: ({ params: { missingPattern } }) => (0, codegen_1.str) `should have property matching pattern '${missingPattern}'`, | ||
params: ({ params: { missingPattern } }) => (0, codegen_1._) `{missingPattern: ${missingPattern}}`, | ||
}; | ||
@@ -26,7 +26,7 @@ function getDef() { | ||
gen.forIn("key", data, (key) => { | ||
gen.assign(matched, codegen_1._ `${_util_1.usePattern(gen, pattern)}.test(${key})`); | ||
gen.assign(matched, (0, codegen_1._) `${(0, _util_1.usePattern)(cxt, pattern)}.test(${key})`); | ||
gen.if(matched, () => gen.break()); | ||
}); | ||
cxt.setParams({ missingPattern: pattern }); | ||
gen.assign(valid, codegen_1.and(valid, matched)); | ||
gen.assign(valid, (0, codegen_1.and)(valid, matched)); | ||
cxt.pass(valid); | ||
@@ -33,0 +33,0 @@ } |
@@ -7,5 +7,5 @@ "use strict"; | ||
const _range_1 = __importDefault(require("./_range")); | ||
const getDef = _range_1.default("range"); | ||
const getDef = (0, _range_1.default)("range"); | ||
exports.default = getDef; | ||
module.exports = getDef; | ||
//# sourceMappingURL=range.js.map |
@@ -21,11 +21,11 @@ "use strict"; | ||
code(cxt) { | ||
const { gen, data, schema } = cxt; | ||
const { data, schema } = cxt; | ||
const regx = getRegExp(schema); | ||
cxt.pass(codegen_1._ `${regx}.test(${data})`); | ||
cxt.pass((0, codegen_1._) `${regx}.test(${data})`); | ||
function getRegExp(sch) { | ||
if (typeof sch == "object") | ||
return _util_1.usePattern(gen, sch.pattern, sch.flags); | ||
return (0, _util_1.usePattern)(cxt, sch.pattern, sch.flags); | ||
const rx = metaRegexp.exec(sch); | ||
if (rx) | ||
return _util_1.usePattern(gen, rx[1], rx[2]); | ||
return (0, _util_1.usePattern)(cxt, rx[1], rx[2]); | ||
throw new Error("cannot parse string into RegExp"); | ||
@@ -32,0 +32,0 @@ } |
@@ -7,8 +7,8 @@ "use strict"; | ||
message: ({ params: { schemaProp } }) => schemaProp | ||
? codegen_1.str `should match case "${schemaProp}" schema` | ||
: codegen_1.str `should match default case schema`, | ||
params: ({ params: { schemaProp } }) => schemaProp ? codegen_1._ `{failingCase: ${schemaProp}}` : codegen_1._ `{failingDefault: true}`, | ||
? (0, codegen_1.str) `should match case "${schemaProp}" schema` | ||
: (0, codegen_1.str) `should match default case schema`, | ||
params: ({ params: { schemaProp } }) => schemaProp ? (0, codegen_1._) `{failingCase: ${schemaProp}}` : (0, codegen_1._) `{failingDefault: true}`, | ||
}; | ||
function getDef(opts) { | ||
const metaSchema = _util_1.metaSchemaRef(opts); | ||
const metaSchema = (0, _util_1.metaSchemaRef)(opts); | ||
return [ | ||
@@ -26,7 +26,7 @@ { | ||
const schValid = gen.name("_valid"); | ||
const value = gen.const("value", codegen_1._ `${schemaCode} === null ? "null" : ${schemaCode}`); | ||
const value = gen.const("value", (0, codegen_1._) `${schemaCode} === null ? "null" : ${schemaCode}`); | ||
gen.if(false); // optimizer should remove it from generated code | ||
for (const schemaProp in parentSchema.selectCases) { | ||
cxt.setParams({ schemaProp }); | ||
gen.elseIf(codegen_1._ `"" + ${value} == ${schemaProp}`); // intentional ==, to match numbers and booleans | ||
gen.elseIf((0, codegen_1._) `"" + ${value} == ${schemaProp}`); // intentional ==, to match numbers and booleans | ||
const schCxt = cxt.subschema({ keyword: "selectCases", schemaProp }, schValid); | ||
@@ -33,0 +33,0 @@ cxt.mergeEvaluated(schCxt, codegen_1.Name); |
@@ -29,7 +29,7 @@ "use strict"; | ||
const config = getEnumCaseCfg(parentSchema); | ||
cfg = gen.scopeValue("obj", { ref: config, code: codegen_1.stringify(config) }); | ||
cfg = gen.scopeValue("obj", { ref: config, code: (0, codegen_1.stringify)(config) }); | ||
} | ||
gen.if(codegen_1._ `typeof ${data} == "string" && ${parentData} !== undefined`, () => { | ||
gen.assign(data, transformExpr(tNames)); | ||
gen.assign(codegen_1._ `${parentData}[${parentDataProperty}]`, data); | ||
gen.if((0, codegen_1._) `typeof ${data} == "string" && ${parentData} !== undefined`, () => { | ||
gen.assign(data, transformExpr(tNames.slice())); | ||
gen.assign((0, codegen_1._) `${parentData}[${parentDataProperty}]`, data); | ||
}); | ||
@@ -44,6 +44,6 @@ function transformExpr(ts) { | ||
ref: transform[t], | ||
code: codegen_1._ `require("ajv-keywords/dist/definitions/transform").transform${codegen_1.getProperty(t)}`, | ||
code: (0, codegen_1._) `require("ajv-keywords/dist/definitions/transform").transform${(0, codegen_1.getProperty)(t)}`, | ||
}); | ||
const arg = transformExpr(ts); | ||
return cfg && t === "toEnumCase" ? codegen_1._ `${func}(${arg}, ${cfg})` : codegen_1._ `${func}(${arg})`; | ||
return cfg && t === "toEnumCase" ? (0, codegen_1._) `${func}(${arg}, ${cfg})` : (0, codegen_1._) `${func}(${arg})`; | ||
} | ||
@@ -50,0 +50,0 @@ }, |
@@ -12,4 +12,4 @@ "use strict"; | ||
cxt.fail(typeof schema == "string" | ||
? codegen_1._ `typeof ${data} != ${schema}` | ||
: codegen_1._ `${schemaValue}.indexOf(typeof ${data}) < 0`); | ||
? (0, codegen_1._) `typeof ${data} != ${schema}` | ||
: (0, codegen_1._) `${schemaValue}.indexOf(typeof ${data}) < 0`); | ||
}, | ||
@@ -16,0 +16,0 @@ metaSchema: { |
@@ -7,5 +7,5 @@ "use strict"; | ||
const allRequired_1 = __importDefault(require("../definitions/allRequired")); | ||
const allRequired = (ajv) => ajv.addKeyword(allRequired_1.default()); | ||
const allRequired = (ajv) => ajv.addKeyword((0, allRequired_1.default)()); | ||
exports.default = allRequired; | ||
module.exports = allRequired; | ||
//# sourceMappingURL=allRequired.js.map |
@@ -7,5 +7,5 @@ "use strict"; | ||
const anyRequired_1 = __importDefault(require("../definitions/anyRequired")); | ||
const anyRequired = (ajv) => ajv.addKeyword(anyRequired_1.default()); | ||
const anyRequired = (ajv) => ajv.addKeyword((0, anyRequired_1.default)()); | ||
exports.default = anyRequired; | ||
module.exports = anyRequired; | ||
//# sourceMappingURL=anyRequired.js.map |
@@ -7,5 +7,5 @@ "use strict"; | ||
const deepProperties_1 = __importDefault(require("../definitions/deepProperties")); | ||
const deepProperties = (ajv, opts) => ajv.addKeyword(deepProperties_1.default(opts)); | ||
const deepProperties = (ajv, opts) => ajv.addKeyword((0, deepProperties_1.default)(opts)); | ||
exports.default = deepProperties; | ||
module.exports = deepProperties; | ||
//# sourceMappingURL=deepProperties.js.map |
@@ -7,5 +7,5 @@ "use strict"; | ||
const deepRequired_1 = __importDefault(require("../definitions/deepRequired")); | ||
const deepRequired = (ajv) => ajv.addKeyword(deepRequired_1.default()); | ||
const deepRequired = (ajv) => ajv.addKeyword((0, deepRequired_1.default)()); | ||
exports.default = deepRequired; | ||
module.exports = deepRequired; | ||
//# sourceMappingURL=deepRequired.js.map |
@@ -7,5 +7,5 @@ "use strict"; | ||
const dynamicDefaults_1 = __importDefault(require("../definitions/dynamicDefaults")); | ||
const dynamicDefaults = (ajv) => ajv.addKeyword(dynamicDefaults_1.default()); | ||
const dynamicDefaults = (ajv) => ajv.addKeyword((0, dynamicDefaults_1.default)()); | ||
exports.default = dynamicDefaults; | ||
module.exports = dynamicDefaults; | ||
//# sourceMappingURL=dynamicDefaults.js.map |
@@ -7,5 +7,5 @@ "use strict"; | ||
const exclusiveRange_1 = __importDefault(require("../definitions/exclusiveRange")); | ||
const exclusiveRange = (ajv) => ajv.addKeyword(exclusiveRange_1.default()); | ||
const exclusiveRange = (ajv) => ajv.addKeyword((0, exclusiveRange_1.default)()); | ||
exports.default = exclusiveRange; | ||
module.exports = exclusiveRange; | ||
//# sourceMappingURL=exclusiveRange.js.map |
@@ -7,5 +7,5 @@ "use strict"; | ||
const instanceof_1 = __importDefault(require("../definitions/instanceof")); | ||
const instanceofPlugin = (ajv) => ajv.addKeyword(instanceof_1.default()); | ||
const instanceofPlugin = (ajv) => ajv.addKeyword((0, instanceof_1.default)()); | ||
exports.default = instanceofPlugin; | ||
module.exports = instanceofPlugin; | ||
//# sourceMappingURL=instanceof.js.map |
@@ -7,5 +7,5 @@ "use strict"; | ||
const oneRequired_1 = __importDefault(require("../definitions/oneRequired")); | ||
const oneRequired = (ajv) => ajv.addKeyword(oneRequired_1.default()); | ||
const oneRequired = (ajv) => ajv.addKeyword((0, oneRequired_1.default)()); | ||
exports.default = oneRequired; | ||
module.exports = oneRequired; | ||
//# sourceMappingURL=oneRequired.js.map |
@@ -7,5 +7,5 @@ "use strict"; | ||
const patternRequired_1 = __importDefault(require("../definitions/patternRequired")); | ||
const patternRequired = (ajv) => ajv.addKeyword(patternRequired_1.default()); | ||
const patternRequired = (ajv) => ajv.addKeyword((0, patternRequired_1.default)()); | ||
exports.default = patternRequired; | ||
module.exports = patternRequired; | ||
//# sourceMappingURL=patternRequired.js.map |
@@ -7,5 +7,5 @@ "use strict"; | ||
const prohibited_1 = __importDefault(require("../definitions/prohibited")); | ||
const prohibited = (ajv) => ajv.addKeyword(prohibited_1.default()); | ||
const prohibited = (ajv) => ajv.addKeyword((0, prohibited_1.default)()); | ||
exports.default = prohibited; | ||
module.exports = prohibited; | ||
//# sourceMappingURL=prohibited.js.map |
@@ -7,5 +7,5 @@ "use strict"; | ||
const range_1 = __importDefault(require("../definitions/range")); | ||
const range = (ajv) => ajv.addKeyword(range_1.default()); | ||
const range = (ajv) => ajv.addKeyword((0, range_1.default)()); | ||
exports.default = range; | ||
module.exports = range; | ||
//# sourceMappingURL=range.js.map |
@@ -7,5 +7,5 @@ "use strict"; | ||
const regexp_1 = __importDefault(require("../definitions/regexp")); | ||
const regexp = (ajv) => ajv.addKeyword(regexp_1.default()); | ||
const regexp = (ajv) => ajv.addKeyword((0, regexp_1.default)()); | ||
exports.default = regexp; | ||
module.exports = regexp; | ||
//# sourceMappingURL=regexp.js.map |
@@ -8,3 +8,3 @@ "use strict"; | ||
const select = (ajv, opts) => { | ||
select_1.default(opts).forEach((d) => ajv.addKeyword(d)); | ||
(0, select_1.default)(opts).forEach((d) => ajv.addKeyword(d)); | ||
return ajv; | ||
@@ -11,0 +11,0 @@ }; |
@@ -7,5 +7,5 @@ "use strict"; | ||
const transform_1 = __importDefault(require("../definitions/transform")); | ||
const transform = (ajv) => ajv.addKeyword(transform_1.default()); | ||
const transform = (ajv) => ajv.addKeyword((0, transform_1.default)()); | ||
exports.default = transform; | ||
module.exports = transform; | ||
//# sourceMappingURL=transform.js.map |
@@ -7,5 +7,5 @@ "use strict"; | ||
const typeof_1 = __importDefault(require("../definitions/typeof")); | ||
const typeofPlugin = (ajv) => ajv.addKeyword(typeof_1.default()); | ||
const typeofPlugin = (ajv) => ajv.addKeyword((0, typeof_1.default)()); | ||
exports.default = typeofPlugin; | ||
module.exports = typeofPlugin; | ||
//# sourceMappingURL=typeof.js.map |
@@ -7,5 +7,5 @@ "use strict"; | ||
const uniqueItemProperties_1 = __importDefault(require("../definitions/uniqueItemProperties")); | ||
const uniqueItemProperties = (ajv) => ajv.addKeyword(uniqueItemProperties_1.default()); | ||
const uniqueItemProperties = (ajv) => ajv.addKeyword((0, uniqueItemProperties_1.default)()); | ||
exports.default = uniqueItemProperties; | ||
module.exports = uniqueItemProperties; | ||
//# sourceMappingURL=uniqueItemProperties.js.map |
{ | ||
"name": "ajv-keywords", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"description": "Additional JSON-Schema keywords for Ajv JSON validator", | ||
@@ -41,3 +41,3 @@ "main": "dist/index.js", | ||
"peerDependencies": { | ||
"ajv": "^8.0.0" | ||
"ajv": "^8.8.2" | ||
}, | ||
@@ -48,7 +48,7 @@ "devDependencies": { | ||
"@types/jest": "^26.0.14", | ||
"@types/node": "^14.11.10", | ||
"@types/node": "^16.4.10", | ||
"@types/uuid": "^8.3.0", | ||
"@typescript-eslint/eslint-plugin": "^4.4.1", | ||
"@typescript-eslint/parser": "^4.4.1", | ||
"ajv": "^8.0.0", | ||
"ajv": "^8.8.2", | ||
"ajv-formats": "^2.0.0", | ||
@@ -58,6 +58,6 @@ "chai": "^4.2.0", | ||
"eslint-config-prettier": "^7.0.0", | ||
"husky": "^4.3.0", | ||
"husky": "^7.0.1", | ||
"jest": "^26.5.3", | ||
"json-schema-test": "^2.0.0", | ||
"lint-staged": "^10.4.2", | ||
"lint-staged": "^11.1.1", | ||
"prettier": "^2.1.2", | ||
@@ -64,0 +64,0 @@ "ts-jest": "^26.4.1", |
@@ -320,12 +320,12 @@ # ajv-keywords | ||
properties: { | ||
foo: {type: 'number'}, | ||
bar: {type: 'number'} | ||
} | ||
allRequired: true | ||
}; | ||
foo: {type: "number"}, | ||
bar: {type: "number"}, | ||
}, | ||
allRequired: true, | ||
} | ||
const validData = { foo: 1, bar: 2 }; | ||
const alsoValidData = { foo: 1, bar: 2, baz: 3 }; | ||
const validData = {foo: 1, bar: 2} | ||
const alsoValidData = {foo: 1, bar: 2, baz: 3} | ||
const invalidDataList = [ {}, { foo: 1 }, { bar: 2 } ]; | ||
const invalidDataList = [{}, {foo: 1}, {bar: 2}] | ||
``` | ||
@@ -537,50 +537,50 @@ | ||
```javascript | ||
require('ajv-keywords')(ajv, 'select'); | ||
require("ajv-keywords")(ajv, "select") | ||
const schema = { | ||
type: "object", | ||
required: ['kind'], | ||
required: ["kind"], | ||
properties: { | ||
kind: { type: 'string' } | ||
kind: {type: "string"}, | ||
}, | ||
select: { $data: '0/kind' }, | ||
select: {$data: "0/kind"}, | ||
selectCases: { | ||
foo: { | ||
required: ['foo'], | ||
required: ["foo"], | ||
properties: { | ||
kind: {}, | ||
foo: { type: 'string' } | ||
foo: {type: "string"}, | ||
}, | ||
additionalProperties: false | ||
additionalProperties: false, | ||
}, | ||
bar: { | ||
required: ['bar'], | ||
required: ["bar"], | ||
properties: { | ||
kind: {}, | ||
bar: { type: 'number' } | ||
bar: {type: "number"}, | ||
}, | ||
additionalProperties: false | ||
} | ||
additionalProperties: false, | ||
}, | ||
}, | ||
selectDefault: { | ||
propertyNames: { | ||
not: { enum: ['foo', 'bar'] } | ||
} | ||
} | ||
}; | ||
not: {enum: ["foo", "bar"]}, | ||
}, | ||
}, | ||
} | ||
const validDataList = [ | ||
{ kind: 'foo', foo: 'any' }, | ||
{ kind: 'bar', bar: 1 }, | ||
{ kind: 'anything_else', not_bar_or_foo: 'any value' } | ||
]; | ||
{kind: "foo", foo: "any"}, | ||
{kind: "bar", bar: 1}, | ||
{kind: "anything_else", not_bar_or_foo: "any value"}, | ||
] | ||
const invalidDataList = [ | ||
{ kind: 'foo' }, // no property foo | ||
{ kind: 'bar' }, // no property bar | ||
{ kind: 'foo', foo: 'any', another: 'any value' }, // additional property | ||
{ kind: 'bar', bar: 1, another: 'any value' }, // additional property | ||
{ kind: 'anything_else', foo: 'any' } // property foo not allowed | ||
{ kind: 'anything_else', bar: 1 } // property bar not allowed | ||
]; | ||
{kind: "foo"}, // no property foo | ||
{kind: "bar"}, // no property bar | ||
{kind: "foo", foo: "any", another: "any value"}, // additional property | ||
{kind: "bar", bar: 1, another: "any value"}, // additional property | ||
{kind: "anything_else", foo: "any"}, // property foo not allowed | ||
{kind: "anything_else", bar: 1}, // property bar not allowed | ||
] | ||
``` | ||
@@ -587,0 +587,0 @@ |
import type {DefinitionOptions} from "./_types" | ||
import type {SchemaObject, CodeGen, Name} from "ajv" | ||
import type {SchemaObject, KeywordCxt, Name} from "ajv" | ||
import {_} from "ajv/dist/compile/codegen" | ||
@@ -11,8 +11,13 @@ | ||
export function usePattern(gen: CodeGen, pattern: string, flags = "u"): Name { | ||
export function usePattern( | ||
{gen, it: {opts}}: KeywordCxt, | ||
pattern: string, | ||
flags = opts.unicodeRegExp ? "u" : "" | ||
): Name { | ||
const rx = new RegExp(pattern, flags) | ||
return gen.scopeValue("pattern", { | ||
key: pattern, | ||
ref: new RegExp(pattern, flags), | ||
key: rx.toString(), | ||
ref: rx, | ||
code: _`new RegExp(${pattern}, ${flags})`, | ||
}) | ||
} |
@@ -29,3 +29,3 @@ import type {CodeKeywordDefinition, KeywordCxt, KeywordErrorDefinition, ErrorObject} from "ajv" | ||
gen.forIn("key", data, (key) => { | ||
gen.assign(matched, _`${usePattern(gen, pattern)}.test(${key})`) | ||
gen.assign(matched, _`${usePattern(cxt, pattern)}.test(${key})`) | ||
gen.if(matched, () => gen.break()) | ||
@@ -32,0 +32,0 @@ }) |
@@ -28,3 +28,3 @@ import type {CodeKeywordDefinition, KeywordCxt, JSONSchemaType, Name} from "ajv" | ||
code(cxt: KeywordCxt) { | ||
const {gen, data, schema} = cxt | ||
const {data, schema} = cxt | ||
const regx = getRegExp(schema) | ||
@@ -34,5 +34,5 @@ cxt.pass(_`${regx}.test(${data})`) | ||
function getRegExp(sch: string | RegexpSchema): Name { | ||
if (typeof sch == "object") return usePattern(gen, sch.pattern, sch.flags) | ||
if (typeof sch == "object") return usePattern(cxt, sch.pattern, sch.flags) | ||
const rx = metaRegexp.exec(sch) | ||
if (rx) return usePattern(gen, rx[1], rx[2]) | ||
if (rx) return usePattern(cxt, rx[1], rx[2]) | ||
throw new Error("cannot parse string into RegExp") | ||
@@ -39,0 +39,0 @@ } |
@@ -51,3 +51,3 @@ import type {CodeKeywordDefinition, AnySchemaObject, KeywordCxt, Code, Name} from "ajv" | ||
gen.if(_`typeof ${data} == "string" && ${parentData} !== undefined`, () => { | ||
gen.assign(data, transformExpr(tNames)) | ||
gen.assign(data, transformExpr(tNames.slice())) | ||
gen.assign(_`${parentData}[${parentDataProperty}]`, data) | ||
@@ -54,0 +54,0 @@ }) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
131806
1949