Socket
Socket
Sign inDemoInstall

ajv

Package Overview
Dependencies
Maintainers
2
Versions
355
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajv - npm Package Compare versions

Comparing version 8.6.2 to 8.6.3

14

dist/compile/codegen/index.js

@@ -453,3 +453,3 @@ "use strict";

code.push(":");
code_1.addCodeArg(code, value);
(0, code_1.addCodeArg)(code, value);
}

@@ -506,4 +506,4 @@ }

const arr = iterable instanceof code_1.Name ? iterable : this.var("_arr", iterable);
return this.forRange("_i", 0, code_1._ `${arr}.length`, (i) => {
this.var(name, code_1._ `${arr}[${i}]`);
return this.forRange("_i", 0, (0, code_1._) `${arr}.length`, (i) => {
this.var(name, (0, code_1._) `${arr}[${i}]`);
forBody(name);

@@ -518,3 +518,3 @@ });

if (this.opts.ownProperties) {
return this.forOf(nameOrPrefix, code_1._ `Object.keys(${obj})`, forBody);
return this.forOf(nameOrPrefix, (0, code_1._) `Object.keys(${obj})`, forBody);
}

@@ -679,3 +679,3 @@ const name = this._scope.toName(nameOrPrefix);

function not(x) {
return typeof x == "boolean" || typeof x == "number" || x === null ? !x : code_1._ `!${par(x)}`;
return typeof x == "boolean" || typeof x == "number" || x === null ? !x : (0, code_1._) `!${par(x)}`;
}

@@ -696,7 +696,7 @@ exports.not = not;

function mappend(op) {
return (x, y) => (x === code_1.nil ? y : y === code_1.nil ? x : code_1._ `${par(x)} ${op} ${par(y)}`);
return (x, y) => (x === code_1.nil ? y : y === code_1.nil ? x : (0, code_1._) `${par(x)} ${op} ${par(y)}`);
}
function par(x) {
return x instanceof code_1.Name ? x : code_1._ `(${x})`;
return x instanceof code_1.Name ? x : (0, code_1._) `(${x})`;
}
//# sourceMappingURL=index.js.map

@@ -53,7 +53,7 @@ "use strict";

this.value = value;
this.scopePath = code_1._ `.${new code_1.Name(property)}[${itemIndex}]`;
this.scopePath = (0, code_1._) `.${new code_1.Name(property)}[${itemIndex}]`;
}
}
exports.ValueScopeName = ValueScopeName;
const line = code_1._ `\n`;
const line = (0, code_1._) `\n`;
class ValueScope extends Scope {

@@ -105,3 +105,3 @@ constructor(opts) {

throw new Error(`CodeGen: name "${name}" has no value`);
return code_1._ `${scopeName}${name.scopePath}`;
return (0, code_1._) `${scopeName}${name.scopePath}`;
});

@@ -130,6 +130,6 @@ }

const def = this.opts.es5 ? exports.varKinds.var : exports.varKinds.const;
code = code_1._ `${code}${def} ${name} = ${c};${this.opts._n}`;
code = (0, code_1._) `${code}${def} ${name} = ${c};${this.opts._n}`;
}
else if ((c = getCode === null || getCode === void 0 ? void 0 : getCode(name))) {
code = code_1._ `${code}${c}${this.opts._n}`;
code = (0, code_1._) `${code}${c}${this.opts._n}`;
}

@@ -136,0 +136,0 @@ else {

@@ -8,8 +8,8 @@ "use strict";

exports.keywordError = {
message: ({ keyword }) => codegen_1.str `must pass "${keyword}" keyword validation`,
message: ({ keyword }) => (0, codegen_1.str) `must pass "${keyword}" keyword validation`,
};
exports.keyword$DataError = {
message: ({ keyword, schemaType }) => schemaType
? codegen_1.str `"${keyword}" keyword must be ${schemaType} ($data)`
: codegen_1.str `"${keyword}" keyword is invalid ($data)`,
? (0, codegen_1.str) `"${keyword}" keyword must be ${schemaType} ($data)`
: (0, codegen_1.str) `"${keyword}" keyword is invalid ($data)`,
};

@@ -24,3 +24,3 @@ function reportError(cxt, error = exports.keywordError, errorPaths, overrideAllErrors) {

else {
returnErrors(it, codegen_1._ `[${errObj}]`);
returnErrors(it, (0, codegen_1._) `[${errObj}]`);
}

@@ -41,3 +41,3 @@ }

gen.assign(names_1.default.errors, errsCount);
gen.if(codegen_1._ `${names_1.default.vErrors} !== null`, () => gen.if(errsCount, () => gen.assign(codegen_1._ `${names_1.default.vErrors}.length`, errsCount), () => gen.assign(names_1.default.vErrors, null)));
gen.if((0, codegen_1._) `${names_1.default.vErrors} !== null`, () => gen.if(errsCount, () => gen.assign((0, codegen_1._) `${names_1.default.vErrors}.length`, errsCount), () => gen.assign(names_1.default.vErrors, null)));
}

@@ -51,8 +51,8 @@ exports.resetErrorsCount = resetErrorsCount;

gen.forRange("i", errsCount, names_1.default.errors, (i) => {
gen.const(err, codegen_1._ `${names_1.default.vErrors}[${i}]`);
gen.if(codegen_1._ `${err}.instancePath === undefined`, () => gen.assign(codegen_1._ `${err}.instancePath`, codegen_1.strConcat(names_1.default.instancePath, it.errorPath)));
gen.assign(codegen_1._ `${err}.schemaPath`, codegen_1.str `${it.errSchemaPath}/${keyword}`);
gen.const(err, (0, codegen_1._) `${names_1.default.vErrors}[${i}]`);
gen.if((0, codegen_1._) `${err}.instancePath === undefined`, () => gen.assign((0, codegen_1._) `${err}.instancePath`, (0, codegen_1.strConcat)(names_1.default.instancePath, it.errorPath)));
gen.assign((0, codegen_1._) `${err}.schemaPath`, (0, codegen_1.str) `${it.errSchemaPath}/${keyword}`);
if (it.opts.verbose) {
gen.assign(codegen_1._ `${err}.schema`, schemaValue);
gen.assign(codegen_1._ `${err}.data`, data);
gen.assign((0, codegen_1._) `${err}.schema`, schemaValue);
gen.assign((0, codegen_1._) `${err}.data`, data);
}

@@ -64,4 +64,4 @@ });

const err = gen.const("err", errObj);
gen.if(codegen_1._ `${names_1.default.vErrors} === null`, () => gen.assign(names_1.default.vErrors, codegen_1._ `[${err}]`), codegen_1._ `${names_1.default.vErrors}.push(${err})`);
gen.code(codegen_1._ `${names_1.default.errors}++`);
gen.if((0, codegen_1._) `${names_1.default.vErrors} === null`, () => gen.assign(names_1.default.vErrors, (0, codegen_1._) `[${err}]`), (0, codegen_1._) `${names_1.default.vErrors}.push(${err})`);
gen.code((0, codegen_1._) `${names_1.default.errors}++`);
}

@@ -71,6 +71,6 @@ function returnErrors(it, errs) {

if (schemaEnv.$async) {
gen.throw(codegen_1._ `new ${it.ValidationError}(${errs})`);
gen.throw((0, codegen_1._) `new ${it.ValidationError}(${errs})`);
}
else {
gen.assign(codegen_1._ `${validateName}.errors`, errs);
gen.assign((0, codegen_1._) `${validateName}.errors`, errs);
gen.return(false);

@@ -91,3 +91,3 @@ }

if (createErrors === false)
return codegen_1._ `{}`;
return (0, codegen_1._) `{}`;
return errorObject(cxt, error, errorPaths);

@@ -106,10 +106,10 @@ }

const instPath = instancePath
? codegen_1.str `${errorPath}${util_1.getErrorPath(instancePath, util_1.Type.Str)}`
? (0, codegen_1.str) `${errorPath}${(0, util_1.getErrorPath)(instancePath, util_1.Type.Str)}`
: errorPath;
return [names_1.default.instancePath, codegen_1.strConcat(names_1.default.instancePath, instPath)];
return [names_1.default.instancePath, (0, codegen_1.strConcat)(names_1.default.instancePath, instPath)];
}
function errorSchemaPath({ keyword, it: { errSchemaPath } }, { schemaPath, parentSchema }) {
let schPath = parentSchema ? errSchemaPath : codegen_1.str `${errSchemaPath}/${keyword}`;
let schPath = parentSchema ? errSchemaPath : (0, codegen_1.str) `${errSchemaPath}/${keyword}`;
if (schemaPath) {
schPath = codegen_1.str `${schPath}${util_1.getErrorPath(schemaPath, util_1.Type.Str)}`;
schPath = (0, codegen_1.str) `${schPath}${(0, util_1.getErrorPath)(schemaPath, util_1.Type.Str)}`;
}

@@ -121,3 +121,3 @@ return [E.schemaPath, schPath];

const { opts, propertyName, topSchemaRef, schemaPath } = it;
keyValues.push([E.keyword, keyword], [E.params, typeof params == "function" ? params(cxt) : params || codegen_1._ `{}`]);
keyValues.push([E.keyword, keyword], [E.params, typeof params == "function" ? params(cxt) : params || (0, codegen_1._) `{}`]);
if (opts.messages) {

@@ -127,3 +127,3 @@ keyValues.push([E.message, typeof message == "function" ? message(cxt) : message]);

if (opts.verbose) {
keyValues.push([E.schema, schemaValue], [E.parentSchema, codegen_1._ `${topSchemaRef}${schemaPath}`], [names_1.default.data, data]);
keyValues.push([E.schema, schemaValue], [E.parentSchema, (0, codegen_1._) `${topSchemaRef}${schemaPath}`], [names_1.default.data, data]);
}

@@ -130,0 +130,0 @@ if (propertyName)

@@ -22,3 +22,3 @@ "use strict";

this.root = env.root || this;
this.baseId = (_a = env.baseId) !== null && _a !== void 0 ? _a : resolve_1.normalizeId(schema === null || schema === void 0 ? void 0 : schema[env.schemaId || "$id"]);
this.baseId = (_a = env.baseId) !== null && _a !== void 0 ? _a : (0, resolve_1.normalizeId)(schema === null || schema === void 0 ? void 0 : schema[env.schemaId || "$id"]);
this.schemaPath = env.schemaPath;

@@ -40,3 +40,3 @@ this.localRefs = env.localRefs;

return _sch;
const rootId = resolve_1.getFullPath(sch.root.baseId); // TODO if getFullPath removed 1 tests fails
const rootId = (0, resolve_1.getFullPath)(sch.root.baseId); // TODO if getFullPath removed 1 tests fails
const { es5, lines } = this.opts.code;

@@ -49,3 +49,3 @@ const { ownProperties } = this.opts;

ref: validation_error_1.default,
code: codegen_1._ `require("ajv/dist/runtime/validation_error").default`,
code: (0, codegen_1._) `require("ajv/dist/runtime/validation_error").default`,
});

@@ -67,3 +67,3 @@ }

topSchemaRef: gen.scopeValue("schema", this.opts.code.source === true
? { ref: sch.schema, code: codegen_1.stringify(sch.schema) }
? { ref: sch.schema, code: (0, codegen_1.stringify)(sch.schema) }
: { ref: sch.schema }),

@@ -78,3 +78,3 @@ validateName,

errSchemaPath: sch.schemaPath || (this.opts.jtd ? "" : "#"),
errorPath: codegen_1._ `""`,
errorPath: (0, codegen_1._) `""`,
opts: this.opts,

@@ -86,3 +86,3 @@ self: this,

this._compilations.add(sch);
validate_1.validateFunctionCode(schemaCxt);
(0, validate_1.validateFunctionCode)(schemaCxt);
gen.optimize(this.opts.code.optimize);

@@ -116,3 +116,3 @@ // gen.optimize(1)

if (validate.source)
validate.source.evaluated = codegen_1.stringify(validate.evaluated);
validate.source.evaluated = (0, codegen_1.stringify)(validate.evaluated);
}

@@ -137,3 +137,3 @@ sch.validate = validate;

var _a;
ref = resolve_1.resolveUrl(baseId, ref);
ref = (0, resolve_1.resolveUrl)(baseId, ref);
const schOrFunc = root.refs[ref];

@@ -155,3 +155,3 @@ if (schOrFunc)

function inlineOrCompile(sch) {
if (resolve_1.inlineRef(sch.schema, this.opts.inlineRefs))
if ((0, resolve_1.inlineRef)(sch.schema, this.opts.inlineRefs))
return sch.schema;

@@ -186,4 +186,4 @@ return sch.validate ? sch : compileSchema.call(this, sch);

const p = URI.parse(ref);
const refPath = resolve_1._getFullPath(p);
let baseId = resolve_1.getFullPath(root.baseId);
const refPath = (0, resolve_1._getFullPath)(p);
let baseId = (0, resolve_1.getFullPath)(root.baseId);
// TODO `Object.keys(root.schema).length > 0` should not be needed - but removing breaks 2 tests

@@ -193,3 +193,3 @@ if (Object.keys(root.schema).length > 0 && refPath === baseId) {

}
const id = resolve_1.normalizeId(refPath);
const id = (0, resolve_1.normalizeId)(refPath);
const schOrRef = this.refs[id] || this.schemas[id];

@@ -206,3 +206,3 @@ if (typeof schOrRef == "string") {

compileSchema.call(this, schOrRef);
if (id === resolve_1.normalizeId(ref)) {
if (id === (0, resolve_1.normalizeId)(ref)) {
const { schema } = schOrRef;

@@ -212,3 +212,3 @@ const { schemaId } = this.opts;

if (schId)
baseId = resolve_1.resolveUrl(baseId, schId);
baseId = (0, resolve_1.resolveUrl)(baseId, schId);
return new SchemaEnv({ schema, schemaId, root, baseId });

@@ -231,16 +231,17 @@ }

for (const part of parsedRef.fragment.slice(1).split("/")) {
if (typeof schema == "boolean")
if (typeof schema === "boolean")
return;
schema = schema[util_1.unescapeFragment(part)];
if (schema === undefined)
const partSchema = schema[(0, util_1.unescapeFragment)(part)];
if (partSchema === undefined)
return;
schema = partSchema;
// TODO PREVENT_SCOPE_CHANGE could be defined in keyword def?
const schId = typeof schema == "object" && schema[this.opts.schemaId];
const schId = typeof schema === "object" && schema[this.opts.schemaId];
if (!PREVENT_SCOPE_CHANGE.has(part) && schId) {
baseId = resolve_1.resolveUrl(baseId, schId);
baseId = (0, resolve_1.resolveUrl)(baseId, schId);
}
}
let env;
if (typeof schema != "boolean" && schema.$ref && !util_1.schemaHasRulesButRef(schema, this.RULES)) {
const $ref = resolve_1.resolveUrl(baseId, schema.$ref);
if (typeof schema != "boolean" && schema.$ref && !(0, util_1.schemaHasRulesButRef)(schema, this.RULES)) {
const $ref = (0, resolve_1.resolveUrl)(baseId, schema.$ref);
env = resolveSchema.call(this, root, $ref);

@@ -247,0 +248,0 @@ }

@@ -68,19 +68,19 @@ "use strict";

exports.default = compileParser;
const undef = codegen_1._ `undefined`;
const undef = (0, codegen_1._) `undefined`;
function parserFunction(cxt) {
const { gen, parseName, char } = cxt;
gen.func(parseName, codegen_1._ `${names_1.default.json}, ${names_1.default.jsonPos}, ${names_1.default.jsonPart}`, false, () => {
gen.func(parseName, (0, codegen_1._) `${names_1.default.json}, ${names_1.default.jsonPos}, ${names_1.default.jsonPart}`, false, () => {
gen.let(names_1.default.data);
gen.let(char);
gen.assign(codegen_1._ `${parseName}.message`, undef);
gen.assign(codegen_1._ `${parseName}.position`, undef);
gen.assign(names_1.default.jsonPos, codegen_1._ `${names_1.default.jsonPos} || 0`);
gen.const(names_1.default.jsonLen, codegen_1._ `${names_1.default.json}.length`);
gen.assign((0, codegen_1._) `${parseName}.message`, undef);
gen.assign((0, codegen_1._) `${parseName}.position`, undef);
gen.assign(names_1.default.jsonPos, (0, codegen_1._) `${names_1.default.jsonPos} || 0`);
gen.const(names_1.default.jsonLen, (0, codegen_1._) `${names_1.default.json}.length`);
parseCode(cxt);
skipWhitespace(cxt);
gen.if(names_1.default.jsonPart, () => {
gen.assign(codegen_1._ `${parseName}.position`, names_1.default.jsonPos);
gen.assign((0, codegen_1._) `${parseName}.position`, names_1.default.jsonPos);
gen.return(names_1.default.data);
});
gen.if(codegen_1._ `${names_1.default.jsonPos} === ${names_1.default.jsonLen}`, () => gen.return(names_1.default.data));
gen.if((0, codegen_1._) `${names_1.default.jsonPos} === ${names_1.default.jsonLen}`, () => gen.return(names_1.default.data));
jsonSyntaxError(cxt);

@@ -113,7 +113,7 @@ });

const ix = gen.let("i", 0);
gen.assign(data, codegen_1._ `[]`);
gen.assign(data, (0, codegen_1._) `[]`);
parseItems(cxt, "]", () => {
const el = gen.let("el");
parseCode({ ...cxt, schema: schema.elements, data: el });
gen.assign(codegen_1._ `${data}[${ix}++]`, el);
gen.assign((0, codegen_1._) `${data}[${ix}++]`, el);
});

@@ -124,3 +124,3 @@ }

parseToken(cxt, "{");
gen.assign(data, codegen_1._ `{}`);
gen.assign(data, (0, codegen_1._) `{}`);
parseItems(cxt, "}", () => parseKeyValue(cxt, schema.values));

@@ -134,3 +134,3 @@ }

const { gen } = cxt;
gen.for(codegen_1._ `;${names_1.default.jsonPos}<${names_1.default.jsonLen} && ${jsonSlice(1)}!==${endToken};`, () => {
gen.for((0, codegen_1._) `;${names_1.default.jsonPos}<${names_1.default.jsonLen} && ${jsonSlice(1)}!==${endToken};`, () => {
block();

@@ -154,3 +154,3 @@ tryParseToken(cxt, ",", () => gen.break(), hasItem);

parseToken(cxt, "{");
gen.assign(data, codegen_1._ `{}`);
gen.assign(data, (0, codegen_1._) `{}`);
const startPos = gen.const("pos", names_1.default.jsonPos);

@@ -163,5 +163,5 @@ const value = gen.let("value");

parseToken(cxt, ":");
gen.if(codegen_1._ `${key} === ${discriminator}`, () => {
gen.if((0, codegen_1._) `${key} === ${discriminator}`, () => {
parseString({ ...cxt, data: tag });
gen.assign(codegen_1._ `${data}[${key}]`, tag);
gen.assign((0, codegen_1._) `${data}[${key}]`, tag);
gen.break();

@@ -172,10 +172,10 @@ }, () => parseEmpty({ ...cxt, data: value }) // can be discarded/skipped

gen.assign(names_1.default.jsonPos, startPos);
gen.if(codegen_1._ `${tag} === undefined`);
parsingError(cxt, codegen_1.str `discriminator tag not found`);
gen.if((0, codegen_1._) `${tag} === undefined`);
parsingError(cxt, (0, codegen_1.str) `discriminator tag not found`);
for (const tagValue in mapping) {
gen.elseIf(codegen_1._ `${tag} === ${tagValue}`);
gen.elseIf((0, codegen_1._) `${tag} === ${tagValue}`);
parseSchemaProperties({ ...cxt, schema: mapping[tagValue] }, discriminator);
}
gen.else();
parsingError(cxt, codegen_1.str `discriminator value not in schema`);
parsingError(cxt, (0, codegen_1.str) `discriminator value not in schema`);
gen.endIf();

@@ -186,3 +186,3 @@ }

parseToken(cxt, "{");
gen.assign(data, codegen_1._ `{}`);
gen.assign(data, (0, codegen_1._) `{}`);
parseSchemaProperties(cxt);

@@ -201,3 +201,3 @@ }

if (discriminator) {
gen.elseIf(codegen_1._ `${key} === ${discriminator}`);
gen.elseIf((0, codegen_1._) `${key} === ${discriminator}`);
const tag = gen.let("tag");

@@ -208,6 +208,6 @@ parseString({ ...cxt, data: tag }); // can be discarded, it is already assigned

if (additionalProperties) {
parseEmpty({ ...cxt, data: codegen_1._ `${data}[${key}]` });
parseEmpty({ ...cxt, data: (0, codegen_1._) `${data}[${key}]` });
}
else {
parsingError(cxt, codegen_1.str `property ${key} not allowed`);
parsingError(cxt, (0, codegen_1.str) `property ${key} not allowed`);
}

@@ -217,5 +217,5 @@ gen.endIf();

if (properties) {
const hasProp = code_1.hasPropFunc(gen);
const allProps = codegen_1.and(...Object.keys(properties).map((p) => codegen_1._ `${hasProp}.call(${data}, ${p})`));
gen.if(codegen_1.not(allProps), () => parsingError(cxt, codegen_1.str `missing required properties`));
const hasProp = (0, code_1.hasPropFunc)(gen);
const allProps = (0, codegen_1.and)(...Object.keys(properties).map((p) => (0, codegen_1._) `${hasProp}.call(${data}, ${p})`));
gen.if((0, codegen_1.not)(allProps), () => parsingError(cxt, (0, codegen_1.str) `missing required properties`));
}

@@ -226,3 +226,3 @@ }

for (const prop in schemas) {
gen.elseIf(codegen_1._ `${key} === ${prop}`);
gen.elseIf((0, codegen_1._) `${key} === ${prop}`);
parsePropertyValue(cxt, key, schemas[prop]);

@@ -232,3 +232,3 @@ }

function parsePropertyValue(cxt, key, schema) {
parseCode({ ...cxt, schema, data: codegen_1._ `${cxt.data}[${key}]` });
parseCode({ ...cxt, schema, data: (0, codegen_1._) `${cxt.data}[${key}]` });
}

@@ -246,9 +246,9 @@ function parseType(cxt) {

parseString(cxt);
const vts = util_1.useFunc(gen, timestamp_1.default);
const vts = (0, util_1.useFunc)(gen, timestamp_1.default);
const { allowDate, parseDate } = self.opts;
const notValid = allowDate ? codegen_1._ `!${vts}(${data}, true)` : codegen_1._ `!${vts}(${data})`;
const notValid = allowDate ? (0, codegen_1._) `!${vts}(${data}, true)` : (0, codegen_1._) `!${vts}(${data})`;
const fail = parseDate
? codegen_1.or(notValid, codegen_1._ `(${data} = new Date(${data}), false)`, codegen_1._ `isNaN(${data}.valueOf())`)
? (0, codegen_1.or)(notValid, (0, codegen_1._) `(${data} = new Date(${data}), false)`, (0, codegen_1._) `isNaN(${data}.valueOf())`)
: notValid;
gen.if(fail, () => parsingError(cxt, codegen_1.str `invalid timestamp`));
gen.if(fail, () => parsingError(cxt, (0, codegen_1.str) `invalid timestamp`));
break;

@@ -265,3 +265,3 @@ }

if (t === "uint32") {
gen.if(codegen_1._ `${data} < 0`, () => parsingError(cxt, codegen_1.str `integer out of range`));
gen.if((0, codegen_1._) `${data} < 0`, () => parsingError(cxt, (0, codegen_1.str) `integer out of range`));
}

@@ -272,3 +272,3 @@ }

parseNumber(cxt, maxDigits);
gen.if(codegen_1._ `${data} < ${min} || ${data} > ${max}`, () => parsingError(cxt, codegen_1.str `integer out of range`));
gen.if((0, codegen_1._) `${data} < ${min} || ${data} > ${max}`, () => parsingError(cxt, (0, codegen_1.str) `integer out of range`));
}

@@ -290,4 +290,4 @@ }

const valueStr = JSON.stringify(value).slice(1); // remove starting quote
gen.elseIf(codegen_1._ `${jsonSlice(valueStr.length)} === ${valueStr}`);
gen.assign(data, codegen_1.str `${value}`);
gen.elseIf((0, codegen_1._) `${jsonSlice(valueStr.length)} === ${valueStr}`);
gen.assign(data, (0, codegen_1.str) `${value}`);
gen.add(names_1.default.jsonPos, valueStr.length);

@@ -302,3 +302,3 @@ }

skipWhitespace(cxt);
gen.if(codegen_1._ `"-0123456789".indexOf(${jsonSlice(1)}) < 0`, () => jsonSyntaxError(cxt), () => parseWith(cxt, parseJson_1.parseJsonNumber, maxDigits));
gen.if((0, codegen_1._) `"-0123456789".indexOf(${jsonSlice(1)}) < 0`, () => jsonSyntaxError(cxt), () => parseWith(cxt, parseJson_1.parseJsonNumber, maxDigits));
}

@@ -317,3 +317,3 @@ function parseBooleanToken(bool, fail) {

throw new ref_error_1.default("", ref, `No definition ${ref}`);
if (!ref_1.hasRef(refSchema))
if (!(0, ref_1.hasRef)(refSchema))
return parseCode({ ...cxt, schema: refSchema });

@@ -327,3 +327,3 @@ const { root } = schemaEnv;

? gen.scopeValue("parse", { ref: sch.parse })
: codegen_1._ `${gen.scopeValue("wrapper", { ref: sch })}.parse`;
: (0, codegen_1._) `${gen.scopeValue("wrapper", { ref: sch })}.parse`;
}

@@ -334,9 +334,9 @@ function parseEmpty(cxt) {

function parseWith(cxt, parseFunc, args) {
partialParse(cxt, util_1.useFunc(cxt.gen, parseFunc), args);
partialParse(cxt, (0, util_1.useFunc)(cxt.gen, parseFunc), args);
}
function partialParse(cxt, parseFunc, args) {
const { gen, data } = cxt;
gen.assign(data, codegen_1._ `${parseFunc}(${names_1.default.json}, ${names_1.default.jsonPos}${args ? codegen_1._ `, ${args}` : codegen_1.nil})`);
gen.assign(names_1.default.jsonPos, codegen_1._ `${parseFunc}.position`);
gen.if(codegen_1._ `${data} === undefined`, () => parsingError(cxt, codegen_1._ `${parseFunc}.message`));
gen.assign(data, (0, codegen_1._) `${parseFunc}(${names_1.default.json}, ${names_1.default.jsonPos}${args ? (0, codegen_1._) `, ${args}` : codegen_1.nil})`);
gen.assign(names_1.default.jsonPos, (0, codegen_1._) `${parseFunc}.position`);
gen.if((0, codegen_1._) `${data} === undefined`, () => parsingError(cxt, (0, codegen_1._) `${parseFunc}.message`));
}

@@ -350,3 +350,3 @@ function parseToken(cxt, tok) {

skipWhitespace(cxt);
gen.if(codegen_1._ `${jsonSlice(n)} === ${tok}`, () => {
gen.if((0, codegen_1._) `${jsonSlice(n)} === ${tok}`, () => {
gen.add(names_1.default.jsonPos, n);

@@ -357,17 +357,17 @@ success === null || success === void 0 ? void 0 : success(cxt);

function skipWhitespace({ gen, char: c }) {
gen.code(codegen_1._ `while((${c}=${names_1.default.json}[${names_1.default.jsonPos}],${c}===" "||${c}==="\\n"||${c}==="\\r"||${c}==="\\t"))${names_1.default.jsonPos}++;`);
gen.code((0, codegen_1._) `while((${c}=${names_1.default.json}[${names_1.default.jsonPos}],${c}===" "||${c}==="\\n"||${c}==="\\r"||${c}==="\\t"))${names_1.default.jsonPos}++;`);
}
function jsonSlice(len) {
return len === 1
? codegen_1._ `${names_1.default.json}[${names_1.default.jsonPos}]`
: codegen_1._ `${names_1.default.json}.slice(${names_1.default.jsonPos}, ${names_1.default.jsonPos}+${len})`;
? (0, codegen_1._) `${names_1.default.json}[${names_1.default.jsonPos}]`
: (0, codegen_1._) `${names_1.default.json}.slice(${names_1.default.jsonPos}, ${names_1.default.jsonPos}+${len})`;
}
function jsonSyntaxError(cxt) {
parsingError(cxt, codegen_1._ `"unexpected token " + ${names_1.default.json}[${names_1.default.jsonPos}]`);
parsingError(cxt, (0, codegen_1._) `"unexpected token " + ${names_1.default.json}[${names_1.default.jsonPos}]`);
}
function parsingError({ gen, parseName }, msg) {
gen.assign(codegen_1._ `${parseName}.message`, msg);
gen.assign(codegen_1._ `${parseName}.position`, names_1.default.jsonPos);
gen.assign((0, codegen_1._) `${parseName}.message`, msg);
gen.assign((0, codegen_1._) `${parseName}.position`, names_1.default.jsonPos);
gen.return(undef);
}
//# sourceMappingURL=parse.js.map

@@ -43,3 +43,3 @@ "use strict";

gen.func(serializeName, names_1.default.data, false, () => {
gen.let(names_1.default.json, codegen_1.str ``);
gen.let(names_1.default.json, (0, codegen_1.str) ``);
serializeCode(cxt);

@@ -83,7 +83,7 @@ gen.return(names_1.default.json);

return serializeForm(cxt);
gen.if(codegen_1._ `${data} === undefined || ${data} === null`, () => gen.add(names_1.default.json, codegen_1._ `"null"`), () => serializeForm(cxt));
gen.if((0, codegen_1._) `${data} === undefined || ${data} === null`, () => gen.add(names_1.default.json, (0, codegen_1._) `"null"`), () => serializeForm(cxt));
}
function serializeElements(cxt) {
const { gen, schema, data } = cxt;
gen.add(names_1.default.json, codegen_1.str `[`);
gen.add(names_1.default.json, (0, codegen_1.str) `[`);
const first = gen.let("first", true);

@@ -94,10 +94,10 @@ gen.forOf("el", data, (el) => {

});
gen.add(names_1.default.json, codegen_1.str `]`);
gen.add(names_1.default.json, (0, codegen_1.str) `]`);
}
function serializeValues(cxt) {
const { gen, schema, data } = cxt;
gen.add(names_1.default.json, codegen_1.str `{`);
gen.add(names_1.default.json, (0, codegen_1.str) `{`);
const first = gen.let("first", true);
gen.forIn("key", data, (key) => serializeKeyValue(cxt, key, schema.values, first));
gen.add(names_1.default.json, codegen_1.str `}`);
gen.add(names_1.default.json, (0, codegen_1.str) `}`);
}

@@ -108,4 +108,4 @@ function serializeKeyValue(cxt, key, schema, first) {

serializeString({ ...cxt, data: key });
gen.add(names_1.default.json, codegen_1.str `:`);
const value = gen.const("value", codegen_1._ `${data}${codegen_1.getProperty(key)}`);
gen.add(names_1.default.json, (0, codegen_1.str) `:`);
const value = gen.const("value", (0, codegen_1._) `${data}${(0, codegen_1.getProperty)(key)}`);
serializeCode({ ...cxt, schema, data: value });

@@ -116,8 +116,8 @@ }

const { discriminator } = schema;
gen.add(names_1.default.json, codegen_1.str `{${JSON.stringify(discriminator)}:`);
const tag = gen.const("tag", codegen_1._ `${data}${codegen_1.getProperty(discriminator)}`);
gen.add(names_1.default.json, (0, codegen_1.str) `{${JSON.stringify(discriminator)}:`);
const tag = gen.const("tag", (0, codegen_1._) `${data}${(0, codegen_1.getProperty)(discriminator)}`);
serializeString({ ...cxt, data: tag });
gen.if(false);
for (const tagValue in schema.mapping) {
gen.elseIf(codegen_1._ `${tag} === ${tagValue}`);
gen.elseIf((0, codegen_1._) `${tag} === ${tagValue}`);
const sch = schema.mapping[tagValue];

@@ -127,9 +127,9 @@ serializeSchemaProperties({ ...cxt, schema: sch }, discriminator);

gen.endIf();
gen.add(names_1.default.json, codegen_1.str `}`);
gen.add(names_1.default.json, (0, codegen_1.str) `}`);
}
function serializeProperties(cxt) {
const { gen } = cxt;
gen.add(names_1.default.json, codegen_1.str `{`);
gen.add(names_1.default.json, (0, codegen_1.str) `{`);
serializeSchemaProperties(cxt);
gen.add(names_1.default.json, codegen_1.str `}`);
gen.add(names_1.default.json, (0, codegen_1.str) `}`);
}

@@ -148,3 +148,3 @@ function serializeSchemaProperties(cxt, discriminator) {

const value = keyValue(key);
gen.if(codegen_1.and(codegen_1._ `${value} !== undefined`, code_1.isOwnProperty(gen, data, key)), () => serializeProperty(key, optionalProperties[key], value));
gen.if((0, codegen_1.and)((0, codegen_1._) `${value} !== undefined`, (0, code_1.isOwnProperty)(gen, data, key)), () => serializeProperty(key, optionalProperties[key], value));
}

@@ -166,3 +166,3 @@ if (schema.additionalProperties) {

function keyValue(key) {
return gen.const("value", codegen_1._ `${data}${codegen_1.getProperty(key)}`);
return gen.const("value", (0, codegen_1._) `${data}${(0, codegen_1.getProperty)(key)}`);
}

@@ -173,8 +173,8 @@ function serializeProperty(key, propSchema, value) {

else
gen.add(names_1.default.json, codegen_1.str `,`);
gen.add(names_1.default.json, codegen_1.str `${JSON.stringify(key)}:`);
gen.add(names_1.default.json, (0, codegen_1.str) `,`);
gen.add(names_1.default.json, (0, codegen_1.str) `${JSON.stringify(key)}:`);
serializeCode({ ...cxt, schema: propSchema, data: value });
}
function isAdditional(key, ps) {
return ps.length ? codegen_1.and(...ps.map((p) => codegen_1._ `${key} !== ${p}`)) : true;
return ps.length ? (0, codegen_1.and)(...ps.map((p) => (0, codegen_1._) `${key} !== ${p}`)) : true;
}

@@ -186,3 +186,3 @@ }

case "boolean":
gen.add(names_1.default.json, codegen_1._ `${data} ? "true" : "false"`);
gen.add(names_1.default.json, (0, codegen_1._) `${data} ? "true" : "false"`);
break;

@@ -193,3 +193,3 @@ case "string":

case "timestamp":
gen.if(codegen_1._ `${data} instanceof Date`, () => gen.add(names_1.default.json, codegen_1._ `'"' + ${data}.toISOString() + '"'`), () => serializeString(cxt));
gen.if((0, codegen_1._) `${data} instanceof Date`, () => gen.add(names_1.default.json, (0, codegen_1._) `'"' + ${data}.toISOString() + '"'`), () => serializeString(cxt));
break;

@@ -201,6 +201,6 @@ default:

function serializeString({ gen, data }) {
gen.add(names_1.default.json, codegen_1._ `${util_1.useFunc(gen, quote_1.default)}(${data})`);
gen.add(names_1.default.json, (0, codegen_1._) `${(0, util_1.useFunc)(gen, quote_1.default)}(${data})`);
}
function serializeNumber({ gen, data }) {
gen.add(names_1.default.json, codegen_1._ `"" + ${data}`);
gen.add(names_1.default.json, (0, codegen_1._) `"" + ${data}`);
}

@@ -213,7 +213,7 @@ function serializeRef(cxt) {

throw new ref_error_1.default("", ref, `No definition ${ref}`);
if (!ref_1.hasRef(refSchema))
if (!(0, ref_1.hasRef)(refSchema))
return serializeCode({ ...cxt, schema: refSchema });
const { root } = schemaEnv;
const sch = compileSerializer.call(self, new __1.SchemaEnv({ schema: refSchema, root }), definitions);
gen.add(names_1.default.json, codegen_1._ `${getSerialize(gen, sch)}(${data})`);
gen.add(names_1.default.json, (0, codegen_1._) `${getSerialize(gen, sch)}(${data})`);
}

@@ -223,10 +223,10 @@ function getSerialize(gen, sch) {

? gen.scopeValue("serialize", { ref: sch.serialize })
: codegen_1._ `${gen.scopeValue("wrapper", { ref: sch })}.serialize`;
: (0, codegen_1._) `${gen.scopeValue("wrapper", { ref: sch })}.serialize`;
}
function serializeEmpty({ gen, data }) {
gen.add(names_1.default.json, codegen_1._ `JSON.stringify(${data})`);
gen.add(names_1.default.json, (0, codegen_1._) `JSON.stringify(${data})`);
}
function addComma({ gen }, first) {
gen.if(first, () => gen.assign(first, false), () => gen.add(names_1.default.json, codegen_1.str `,`));
gen.if(first, () => gen.assign(first, false), () => gen.add(names_1.default.json, (0, codegen_1.str) `,`));
}
//# sourceMappingURL=serialize.js.map

@@ -7,4 +7,4 @@ "use strict";

super(msg || `can't resolve reference ${ref} from id ${baseId}`);
this.missingRef = resolve_1.resolveUrl(baseId, ref);
this.missingSchema = resolve_1.normalizeId(resolve_1.getFullPath(this.missingRef));
this.missingRef = (0, resolve_1.resolveUrl)(baseId, ref);
this.missingSchema = (0, resolve_1.normalizeId)((0, resolve_1.getFullPath)(this.missingRef));
}

@@ -11,0 +11,0 @@ }

@@ -12,2 +12,2 @@ import type { AnySchema, AnySchemaObject } from "../types";

export declare function resolveUrl(baseId: string, id: string): string;
export declare function getSchemaRefs(this: Ajv, schema: AnySchema): LocalRefs;
export declare function getSchemaRefs(this: Ajv, schema: AnySchema, baseId: string): LocalRefs;

@@ -65,3 +65,3 @@ "use strict";

if (typeof schema[key] == "object") {
util_1.eachItem(schema[key], (sch) => (count += countKeys(sch)));
(0, util_1.eachItem)(schema[key], (sch) => (count += countKeys(sch)));
}

@@ -95,7 +95,7 @@ if (count === Infinity)

const ANCHOR = /^[a-z_][-a-z0-9._]*$/i;
function getSchemaRefs(schema) {
function getSchemaRefs(schema, baseId) {
if (typeof schema == "boolean")
return {};
const { schemaId } = this.opts;
const schId = normalizeId(schema[schemaId]);
const schId = normalizeId(schema[schemaId] || baseId);
const baseIds = { "": schId };

@@ -102,0 +102,0 @@ const pathPrefix = getFullPath(schId, false);

@@ -59,5 +59,5 @@ "use strict";

if (typeof schema == "string")
return codegen_1._ `${schema}`;
return (0, codegen_1._) `${schema}`;
}
return codegen_1._ `${topSchemaRef}${schemaPath}${codegen_1.getProperty(keyword)}`;
return (0, codegen_1._) `${topSchemaRef}${schemaPath}${(0, codegen_1.getProperty)(keyword)}`;
}

@@ -107,6 +107,6 @@ exports.schemaRefOrVal = schemaRefOrVal;

props: makeMergeEvaluated({
mergeNames: (gen, from, to) => gen.if(codegen_1._ `${to} !== true && ${from} !== undefined`, () => {
gen.if(codegen_1._ `${from} === true`, () => gen.assign(to, true), () => gen.assign(to, codegen_1._ `${to} || {}`).code(codegen_1._ `Object.assign(${to}, ${from})`));
mergeNames: (gen, from, to) => gen.if((0, codegen_1._) `${to} !== true && ${from} !== undefined`, () => {
gen.if((0, codegen_1._) `${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1._) `${to} || {}`).code((0, codegen_1._) `Object.assign(${to}, ${from})`));
}),
mergeToName: (gen, from, to) => gen.if(codegen_1._ `${to} !== true`, () => {
mergeToName: (gen, from, to) => gen.if((0, codegen_1._) `${to} !== true`, () => {
if (from === true) {

@@ -116,3 +116,3 @@ gen.assign(to, true);

else {
gen.assign(to, codegen_1._ `${to} || {}`);
gen.assign(to, (0, codegen_1._) `${to} || {}`);
setEvaluated(gen, to, from);

@@ -125,4 +125,4 @@ }

items: makeMergeEvaluated({
mergeNames: (gen, from, to) => gen.if(codegen_1._ `${to} !== true && ${from} !== undefined`, () => gen.assign(to, codegen_1._ `${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
mergeToName: (gen, from, to) => gen.if(codegen_1._ `${to} !== true`, () => gen.assign(to, from === true ? true : codegen_1._ `${to} > ${from} ? ${to} : ${from}`)),
mergeNames: (gen, from, to) => gen.if((0, codegen_1._) `${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1._) `${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
mergeToName: (gen, from, to) => gen.if((0, codegen_1._) `${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1._) `${to} > ${from} ? ${to} : ${from}`)),
mergeValues: (from, to) => (from === true ? true : Math.max(from, to)),

@@ -135,3 +135,3 @@ resultToName: (gen, items) => gen.var("items", items),

return gen.var("props", true);
const props = gen.var("props", codegen_1._ `{}`);
const props = gen.var("props", (0, codegen_1._) `{}`);
if (ps !== undefined)

@@ -143,3 +143,3 @@ setEvaluated(gen, props, ps);

function setEvaluated(gen, props, ps) {
Object.keys(ps).forEach((p) => gen.assign(codegen_1._ `${props}${codegen_1.getProperty(p)}`, true));
Object.keys(ps).forEach((p) => gen.assign((0, codegen_1._) `${props}${(0, codegen_1.getProperty)(p)}`, true));
}

@@ -166,9 +166,9 @@ exports.setEvaluated = setEvaluated;

? isNumber
? codegen_1._ `"[" + ${dataProp} + "]"`
: codegen_1._ `"['" + ${dataProp} + "']"`
? (0, codegen_1._) `"[" + ${dataProp} + "]"`
: (0, codegen_1._) `"['" + ${dataProp} + "']"`
: isNumber
? codegen_1._ `"/" + ${dataProp}`
: codegen_1._ `"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`; // TODO maybe use global escapePointer
? (0, codegen_1._) `"/" + ${dataProp}`
: (0, codegen_1._) `"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`; // TODO maybe use global escapePointer
}
return jsPropertySyntax ? codegen_1.getProperty(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
return jsPropertySyntax ? (0, codegen_1.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
}

@@ -175,0 +175,0 @@ exports.getErrorPath = getErrorPath;

@@ -19,3 +19,3 @@ "use strict";

else {
gen.assign(codegen_1._ `${validateName}.errors`, null);
gen.assign((0, codegen_1._) `${validateName}.errors`, null);
gen.return(true);

@@ -49,4 +49,4 @@ }

};
errors_1.reportError(cxt, boolError, undefined, overrideAllErrors);
(0, errors_1.reportError)(cxt, boolError, undefined, overrideAllErrors);
}
//# sourceMappingURL=boolSchema.js.map

@@ -42,3 +42,3 @@ "use strict";

const checkTypes = types.length > 0 &&
!(coerceTo.length === 0 && types.length === 1 && applicability_1.schemaHasRulesForType(it, types[0]));
!(coerceTo.length === 0 && types.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types[0]));
if (checkTypes) {

@@ -64,11 +64,11 @@ const wrongType = checkDataTypes(types, data, opts.strictNumbers, DataType.Wrong);

const { gen, data, opts } = it;
const dataType = gen.let("dataType", codegen_1._ `typeof ${data}`);
const coerced = gen.let("coerced", codegen_1._ `undefined`);
const dataType = gen.let("dataType", (0, codegen_1._) `typeof ${data}`);
const coerced = gen.let("coerced", (0, codegen_1._) `undefined`);
if (opts.coerceTypes === "array") {
gen.if(codegen_1._ `${dataType} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen
.assign(data, codegen_1._ `${data}[0]`)
.assign(dataType, codegen_1._ `typeof ${data}`)
gen.if((0, codegen_1._) `${dataType} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen
.assign(data, (0, codegen_1._) `${data}[0]`)
.assign(dataType, (0, codegen_1._) `typeof ${data}`)
.if(checkDataTypes(types, data, opts.strictNumbers), () => gen.assign(coerced, data)));
}
gen.if(codegen_1._ `${coerced} !== undefined`);
gen.if((0, codegen_1._) `${coerced} !== undefined`);
for (const t of coerceTo) {

@@ -82,3 +82,3 @@ if (COERCIBLE.has(t) || (t === "array" && opts.coerceTypes === "array")) {

gen.endIf();
gen.if(codegen_1._ `${coerced} !== undefined`, () => {
gen.if((0, codegen_1._) `${coerced} !== undefined`, () => {
gen.assign(data, coerced);

@@ -91,28 +91,28 @@ assignParentData(it, coerced);

gen
.elseIf(codegen_1._ `${dataType} == "number" || ${dataType} == "boolean"`)
.assign(coerced, codegen_1._ `"" + ${data}`)
.elseIf(codegen_1._ `${data} === null`)
.assign(coerced, codegen_1._ `""`);
.elseIf((0, codegen_1._) `${dataType} == "number" || ${dataType} == "boolean"`)
.assign(coerced, (0, codegen_1._) `"" + ${data}`)
.elseIf((0, codegen_1._) `${data} === null`)
.assign(coerced, (0, codegen_1._) `""`);
return;
case "number":
gen
.elseIf(codegen_1._ `${dataType} == "boolean" || ${data} === null
.elseIf((0, codegen_1._) `${dataType} == "boolean" || ${data} === null
|| (${dataType} == "string" && ${data} && ${data} == +${data})`)
.assign(coerced, codegen_1._ `+${data}`);
.assign(coerced, (0, codegen_1._) `+${data}`);
return;
case "integer":
gen
.elseIf(codegen_1._ `${dataType} === "boolean" || ${data} === null
.elseIf((0, codegen_1._) `${dataType} === "boolean" || ${data} === null
|| (${dataType} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`)
.assign(coerced, codegen_1._ `+${data}`);
.assign(coerced, (0, codegen_1._) `+${data}`);
return;
case "boolean":
gen
.elseIf(codegen_1._ `${data} === "false" || ${data} === 0 || ${data} === null`)
.elseIf((0, codegen_1._) `${data} === "false" || ${data} === 0 || ${data} === null`)
.assign(coerced, false)
.elseIf(codegen_1._ `${data} === "true" || ${data} === 1`)
.elseIf((0, codegen_1._) `${data} === "true" || ${data} === 1`)
.assign(coerced, true);
return;
case "null":
gen.elseIf(codegen_1._ `${data} === "" || ${data} === 0 || ${data} === false`);
gen.elseIf((0, codegen_1._) `${data} === "" || ${data} === 0 || ${data} === false`);
gen.assign(coerced, null);

@@ -122,5 +122,5 @@ return;

gen
.elseIf(codegen_1._ `${dataType} === "string" || ${dataType} === "number"
.elseIf((0, codegen_1._) `${dataType} === "string" || ${dataType} === "number"
|| ${dataType} === "boolean" || ${data} === null`)
.assign(coerced, codegen_1._ `[${data}]`);
.assign(coerced, (0, codegen_1._) `[${data}]`);
}

@@ -131,3 +131,3 @@ }

// TODO use gen.property
gen.if(codegen_1._ `${parentData} !== undefined`, () => gen.assign(codegen_1._ `${parentData}[${parentDataProperty}]`, expr));
gen.if((0, codegen_1._) `${parentData} !== undefined`, () => gen.assign((0, codegen_1._) `${parentData}[${parentDataProperty}]`, expr));
}

@@ -139,11 +139,11 @@ function checkDataType(dataType, data, strictNums, correct = DataType.Correct) {

case "null":
return codegen_1._ `${data} ${EQ} null`;
return (0, codegen_1._) `${data} ${EQ} null`;
case "array":
cond = codegen_1._ `Array.isArray(${data})`;
cond = (0, codegen_1._) `Array.isArray(${data})`;
break;
case "object":
cond = codegen_1._ `${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
cond = (0, codegen_1._) `${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
break;
case "integer":
cond = numCond(codegen_1._ `!(${data} % 1) && !isNaN(${data})`);
cond = numCond((0, codegen_1._) `!(${data} % 1) && !isNaN(${data})`);
break;

@@ -154,7 +154,7 @@ case "number":

default:
return codegen_1._ `typeof ${data} ${EQ} ${dataType}`;
return (0, codegen_1._) `typeof ${data} ${EQ} ${dataType}`;
}
return correct === DataType.Correct ? cond : codegen_1.not(cond);
return correct === DataType.Correct ? cond : (0, codegen_1.not)(cond);
function numCond(_cond = codegen_1.nil) {
return codegen_1.and(codegen_1._ `typeof ${data} == "number"`, _cond, strictNums ? codegen_1._ `isFinite(${data})` : codegen_1.nil);
return (0, codegen_1.and)((0, codegen_1._) `typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_1._) `isFinite(${data})` : codegen_1.nil);
}

@@ -168,6 +168,6 @@ }

let cond;
const types = util_1.toHash(dataTypes);
const types = (0, util_1.toHash)(dataTypes);
if (types.array && types.object) {
const notObj = codegen_1._ `typeof ${data} != "object"`;
cond = types.null ? notObj : codegen_1._ `!${data} || ${notObj}`;
const notObj = (0, codegen_1._) `typeof ${data} != "object"`;
cond = types.null ? notObj : (0, codegen_1._) `!${data} || ${notObj}`;
delete types.null;

@@ -183,3 +183,3 @@ delete types.array;

for (const t in types)
cond = codegen_1.and(cond, checkDataType(t, data, strictNums, correct));
cond = (0, codegen_1.and)(cond, checkDataType(t, data, strictNums, correct));
return cond;

@@ -190,7 +190,7 @@ }

message: ({ schema }) => `must be ${schema}`,
params: ({ schema, schemaValue }) => typeof schema == "string" ? codegen_1._ `{type: ${schema}}` : codegen_1._ `{type: ${schemaValue}}`,
params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1._) `{type: ${schema}}` : (0, codegen_1._) `{type: ${schemaValue}}`,
};
function reportTypeError(it) {
const cxt = getTypeErrorContext(it);
errors_1.reportError(cxt, typeError);
(0, errors_1.reportError)(cxt, typeError);
}

@@ -200,3 +200,3 @@ exports.reportTypeError = reportTypeError;

const { gen, data, schema } = it;
const schemaCode = util_1.schemaRefOrVal(it, schema, "type");
const schemaCode = (0, util_1.schemaRefOrVal)(it, schema, "type");
return {

@@ -203,0 +203,0 @@ gen,

@@ -22,15 +22,15 @@ "use strict";

return;
const childData = codegen_1._ `${data}${codegen_1.getProperty(prop)}`;
const childData = (0, codegen_1._) `${data}${(0, codegen_1.getProperty)(prop)}`;
if (compositeRule) {
util_1.checkStrictMode(it, `default is ignored for: ${childData}`);
(0, util_1.checkStrictMode)(it, `default is ignored for: ${childData}`);
return;
}
let condition = codegen_1._ `${childData} === undefined`;
let condition = (0, codegen_1._) `${childData} === undefined`;
if (opts.useDefaults === "empty") {
condition = codegen_1._ `${condition} || ${childData} === null || ${childData} === ""`;
condition = (0, codegen_1._) `${condition} || ${childData} === null || ${childData} === ""`;
}
// `${childData} === undefined` +
// (opts.useDefaults === "empty" ? ` || ${childData} === null || ${childData} === ""` : "")
gen.if(condition, codegen_1._ `${childData} = ${codegen_1.stringify(defaultValue)}`);
gen.if(condition, (0, codegen_1._) `${childData} = ${(0, codegen_1.stringify)(defaultValue)}`);
}
//# sourceMappingURL=defaults.js.map

@@ -25,3 +25,3 @@ "use strict";

}
validateFunction(it, () => boolSchema_1.topBoolOrEmptySchema(it));
validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
}

@@ -31,4 +31,4 @@ exports.validateFunctionCode = validateFunctionCode;

if (opts.code.es5) {
gen.func(validateName, codegen_1._ `${names_1.default.data}, ${names_1.default.valCxt}`, schemaEnv.$async, () => {
gen.code(codegen_1._ `"use strict"; ${funcSourceUrl(schema, opts)}`);
gen.func(validateName, (0, codegen_1._) `${names_1.default.data}, ${names_1.default.valCxt}`, schemaEnv.$async, () => {
gen.code((0, codegen_1._) `"use strict"; ${funcSourceUrl(schema, opts)}`);
destructureValCxtES5(gen, opts);

@@ -39,23 +39,23 @@ gen.code(body);

else {
gen.func(validateName, codegen_1._ `${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
gen.func(validateName, (0, codegen_1._) `${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
}
}
function destructureValCxt(opts) {
return codegen_1._ `{${names_1.default.instancePath}="", ${names_1.default.parentData}, ${names_1.default.parentDataProperty}, ${names_1.default.rootData}=${names_1.default.data}${opts.dynamicRef ? codegen_1._ `, ${names_1.default.dynamicAnchors}={}` : codegen_1.nil}}={}`;
return (0, codegen_1._) `{${names_1.default.instancePath}="", ${names_1.default.parentData}, ${names_1.default.parentDataProperty}, ${names_1.default.rootData}=${names_1.default.data}${opts.dynamicRef ? (0, codegen_1._) `, ${names_1.default.dynamicAnchors}={}` : codegen_1.nil}}={}`;
}
function destructureValCxtES5(gen, opts) {
gen.if(names_1.default.valCxt, () => {
gen.var(names_1.default.instancePath, codegen_1._ `${names_1.default.valCxt}.${names_1.default.instancePath}`);
gen.var(names_1.default.parentData, codegen_1._ `${names_1.default.valCxt}.${names_1.default.parentData}`);
gen.var(names_1.default.parentDataProperty, codegen_1._ `${names_1.default.valCxt}.${names_1.default.parentDataProperty}`);
gen.var(names_1.default.rootData, codegen_1._ `${names_1.default.valCxt}.${names_1.default.rootData}`);
gen.var(names_1.default.instancePath, (0, codegen_1._) `${names_1.default.valCxt}.${names_1.default.instancePath}`);
gen.var(names_1.default.parentData, (0, codegen_1._) `${names_1.default.valCxt}.${names_1.default.parentData}`);
gen.var(names_1.default.parentDataProperty, (0, codegen_1._) `${names_1.default.valCxt}.${names_1.default.parentDataProperty}`);
gen.var(names_1.default.rootData, (0, codegen_1._) `${names_1.default.valCxt}.${names_1.default.rootData}`);
if (opts.dynamicRef)
gen.var(names_1.default.dynamicAnchors, codegen_1._ `${names_1.default.valCxt}.${names_1.default.dynamicAnchors}`);
gen.var(names_1.default.dynamicAnchors, (0, codegen_1._) `${names_1.default.valCxt}.${names_1.default.dynamicAnchors}`);
}, () => {
gen.var(names_1.default.instancePath, codegen_1._ `""`);
gen.var(names_1.default.parentData, codegen_1._ `undefined`);
gen.var(names_1.default.parentDataProperty, codegen_1._ `undefined`);
gen.var(names_1.default.instancePath, (0, codegen_1._) `""`);
gen.var(names_1.default.parentData, (0, codegen_1._) `undefined`);
gen.var(names_1.default.parentDataProperty, (0, codegen_1._) `undefined`);
gen.var(names_1.default.rootData, names_1.default.data);
if (opts.dynamicRef)
gen.var(names_1.default.dynamicAnchors, codegen_1._ `{}`);
gen.var(names_1.default.dynamicAnchors, (0, codegen_1._) `{}`);
});

@@ -81,9 +81,9 @@ }

const { gen, validateName } = it;
it.evaluated = gen.const("evaluated", codegen_1._ `${validateName}.evaluated`);
gen.if(codegen_1._ `${it.evaluated}.dynamicProps`, () => gen.assign(codegen_1._ `${it.evaluated}.props`, codegen_1._ `undefined`));
gen.if(codegen_1._ `${it.evaluated}.dynamicItems`, () => gen.assign(codegen_1._ `${it.evaluated}.items`, codegen_1._ `undefined`));
it.evaluated = gen.const("evaluated", (0, codegen_1._) `${validateName}.evaluated`);
gen.if((0, codegen_1._) `${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1._) `${it.evaluated}.props`, (0, codegen_1._) `undefined`));
gen.if((0, codegen_1._) `${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1._) `${it.evaluated}.items`, (0, codegen_1._) `undefined`));
}
function funcSourceUrl(schema, opts) {
const schId = typeof schema == "object" && schema[opts.schemaId];
return schId && (opts.code.source || opts.code.process) ? codegen_1._ `/*# sourceURL=${schId} */` : codegen_1.nil;
return schId && (opts.code.source || opts.code.process) ? (0, codegen_1._) `/*# sourceURL=${schId} */` : codegen_1.nil;
}

@@ -99,3 +99,3 @@ // schema compilation - this function is used recursively to generate code for sub-schemas

}
boolSchema_1.boolOrEmptySchema(it, valid);
(0, boolSchema_1.boolOrEmptySchema)(it, valid);
}

@@ -122,6 +122,6 @@ function schemaCxtHasRules({ schema, self }) {

// TODO var
gen.var(valid, codegen_1._ `${errsCount} === ${names_1.default.errors}`);
gen.var(valid, (0, codegen_1._) `${errsCount} === ${names_1.default.errors}`);
}
function checkKeywords(it) {
util_1.checkUnknownRules(it);
(0, util_1.checkUnknownRules)(it);
checkRefsAndKeywords(it);

@@ -132,4 +132,4 @@ }

return schemaKeywords(it, [], false, errsCount);
const types = dataType_1.getSchemaTypes(it.schema);
const checkedTypes = dataType_1.coerceAndCheckDataType(it, types);
const types = (0, dataType_1.getSchemaTypes)(it.schema);
const checkedTypes = (0, dataType_1.coerceAndCheckDataType)(it, types);
schemaKeywords(it, types, !checkedTypes, errsCount);

@@ -139,3 +139,3 @@ }

const { schema, errSchemaPath, opts, self } = it;
if (schema.$ref && opts.ignoreKeywordsWithRef && util_1.schemaHasRulesButRef(schema, self.RULES)) {
if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1.schemaHasRulesButRef)(schema, self.RULES)) {
self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);

@@ -147,3 +147,3 @@ }

if (schema.default !== undefined && opts.useDefaults && opts.strictSchema) {
util_1.checkStrictMode(it, "default is ignored in the schema root");
(0, util_1.checkStrictMode)(it, "default is ignored in the schema root");
}

@@ -154,3 +154,3 @@ }

if (schId)
it.baseId = resolve_1.resolveUrl(it.baseId, schId);
it.baseId = (0, resolve_1.resolveUrl)(it.baseId, schId);
}

@@ -164,8 +164,8 @@ function checkAsyncSchema(it) {

if (opts.$comment === true) {
gen.code(codegen_1._ `${names_1.default.self}.logger.log(${msg})`);
gen.code((0, codegen_1._) `${names_1.default.self}.logger.log(${msg})`);
}
else if (typeof opts.$comment == "function") {
const schemaPath = codegen_1.str `${errSchemaPath}/$comment`;
const schemaPath = (0, codegen_1.str) `${errSchemaPath}/$comment`;
const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
gen.code(codegen_1._ `${names_1.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
gen.code((0, codegen_1._) `${names_1.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
}

@@ -177,9 +177,9 @@ }

// TODO assign unevaluated
gen.if(codegen_1._ `${names_1.default.errors} === 0`, () => gen.return(names_1.default.data), () => gen.throw(codegen_1._ `new ${ValidationError}(${names_1.default.vErrors})`));
gen.if((0, codegen_1._) `${names_1.default.errors} === 0`, () => gen.return(names_1.default.data), () => gen.throw((0, codegen_1._) `new ${ValidationError}(${names_1.default.vErrors})`));
}
else {
gen.assign(codegen_1._ `${validateName}.errors`, names_1.default.vErrors);
gen.assign((0, codegen_1._) `${validateName}.errors`, names_1.default.vErrors);
if (opts.unevaluated)
assignEvaluated(it);
gen.return(codegen_1._ `${names_1.default.errors} === 0`);
gen.return((0, codegen_1._) `${names_1.default.errors} === 0`);
}

@@ -189,5 +189,5 @@ }

if (props instanceof codegen_1.Name)
gen.assign(codegen_1._ `${evaluated}.props`, props);
gen.assign((0, codegen_1._) `${evaluated}.props`, props);
if (items instanceof codegen_1.Name)
gen.assign(codegen_1._ `${evaluated}.items`, items);
gen.assign((0, codegen_1._) `${evaluated}.items`, items);
}

@@ -197,3 +197,3 @@ function schemaKeywords(it, types, typeErrors, errsCount) {

const { RULES } = self;
if (schema.$ref && (opts.ignoreKeywordsWithRef || !util_1.schemaHasRulesButRef(schema, RULES))) {
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1.schemaHasRulesButRef)(schema, RULES))) {
gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition)); // TODO typecast

@@ -210,10 +210,10 @@ return;

function groupKeywords(group) {
if (!applicability_1.shouldUseGroup(schema, group))
if (!(0, applicability_1.shouldUseGroup)(schema, group))
return;
if (group.type) {
gen.if(dataType_2.checkDataType(group.type, data, opts.strictNumbers));
gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
iterateKeywords(it, group);
if (types.length === 1 && types[0] === group.type && typeErrors) {
gen.else();
dataType_2.reportTypeError(it);
(0, dataType_2.reportTypeError)(it);
}

@@ -227,3 +227,3 @@ gen.endIf();

if (!allErrors)
gen.if(codegen_1._ `${names_1.default.errors} === ${errsCount || 0}`);
gen.if((0, codegen_1._) `${names_1.default.errors} === ${errsCount || 0}`);
}

@@ -234,6 +234,6 @@ }

if (useDefaults)
defaults_1.assignDefaults(it, group.type);
(0, defaults_1.assignDefaults)(it, group.type);
gen.block(() => {
for (const rule of group.rules) {
if (applicability_1.shouldUseRule(schema, rule)) {
if ((0, applicability_1.shouldUseRule)(schema, rule)) {
keywordCode(it, rule.keyword, rule.definition, group.type);

@@ -275,3 +275,3 @@ }

const rule = rules[keyword];
if (typeof rule == "object" && applicability_1.shouldUseRule(it.schema, rule)) {
if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) {
const { type } = rule.definition;

@@ -293,7 +293,7 @@ if (type.length && !type.some((t) => hasApplicableType(ts, t))) {

msg += ` at "${schemaPath}" (strictTypes)`;
util_1.checkStrictMode(it, msg, it.opts.strictTypes);
(0, util_1.checkStrictMode)(it, msg, it.opts.strictTypes);
}
class KeywordCxt {
constructor(it, def, keyword) {
keyword_1.validateKeywordUsage(it, def, keyword);
(0, keyword_1.validateKeywordUsage)(it, def, keyword);
this.gen = it.gen;

@@ -305,3 +305,3 @@ this.allErrors = it.allErrors;

this.$data = def.$data && it.opts.$data && this.schema && this.schema.$data;
this.schemaValue = util_1.schemaRefOrVal(it, this.schema, keyword, this.$data);
this.schemaValue = (0, util_1.schemaRefOrVal)(it, this.schema, keyword, this.$data);
this.schemaType = def.schemaType;

@@ -317,3 +317,3 @@ this.parentSchema = it.schema;

this.schemaCode = this.schemaValue;
if (!keyword_1.validSchemaType(this.schema, def.schemaType, def.allowUndefined)) {
if (!(0, keyword_1.validSchemaType)(this.schema, def.schemaType, def.allowUndefined)) {
throw new Error(`${keyword} value must be ${JSON.stringify(def.schemaType)}`);

@@ -327,3 +327,3 @@ }

result(condition, successAction, failAction) {
this.failResult(codegen_1.not(condition), successAction, failAction);
this.failResult((0, codegen_1.not)(condition), successAction, failAction);
}

@@ -350,3 +350,3 @@ failResult(condition, successAction, failAction) {

pass(condition, failAction) {
this.failResult(codegen_1.not(condition), undefined, failAction);
this.failResult((0, codegen_1.not)(condition), undefined, failAction);
}

@@ -371,3 +371,3 @@ fail(condition) {

const { schemaCode } = this;
this.fail(codegen_1._ `${schemaCode} !== undefined && (${codegen_1.or(this.invalid$data(), condition)})`);
this.fail((0, codegen_1._) `${schemaCode} !== undefined && (${(0, codegen_1.or)(this.invalid$data(), condition)})`);
}

@@ -388,3 +388,3 @@ error(append, errorParams, errorPaths) {

$dataError() {
errors_1.reportError(this, this.def.$dataError || errors_1.keyword$DataError);
(0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
}

@@ -394,3 +394,3 @@ reset() {

throw new Error('add "trackErrors" to keyword definition');
errors_1.resetErrorsCount(this.gen, this.errsCount);
(0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
}

@@ -417,3 +417,3 @@ ok(cond) {

const { gen, schemaCode, schemaType, def } = this;
gen.if(codegen_1.or(codegen_1._ `${schemaCode} === undefined`, $dataValid));
gen.if((0, codegen_1.or)((0, codegen_1._) `${schemaCode} === undefined`, $dataValid));
if (valid !== codegen_1.nil)

@@ -431,3 +431,3 @@ gen.assign(valid, true);

const { gen, schemaCode, schemaType, def, it } = this;
return codegen_1.or(wrong$DataType(), invalid$DataSchema());
return (0, codegen_1.or)(wrong$DataType(), invalid$DataSchema());
function wrong$DataType() {

@@ -439,3 +439,3 @@ if (schemaType.length) {

const st = Array.isArray(schemaType) ? schemaType : [schemaType];
return codegen_1._ `${dataType_2.checkDataTypes(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
return (0, codegen_1._) `${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
}

@@ -447,3 +447,3 @@ return codegen_1.nil;

const validateSchemaRef = gen.scopeValue("validate$data", { ref: def.validateSchema }); // TODO value.code for standalone
return codegen_1._ `!${validateSchemaRef}(${schemaCode})`;
return (0, codegen_1._) `!${validateSchemaRef}(${schemaCode})`;
}

@@ -454,5 +454,5 @@ return codegen_1.nil;

subschema(appl, valid) {
const subschema = subschema_1.getSubschema(this.it, appl);
subschema_1.extendSubschemaData(subschema, this.it, appl);
subschema_1.extendSubschemaMode(subschema, appl);
const subschema = (0, subschema_1.getSubschema)(this.it, appl);
(0, subschema_1.extendSubschemaData)(subschema, this.it, appl);
(0, subschema_1.extendSubschemaMode)(subschema, appl);
const nextContext = { ...this.it, ...subschema, items: undefined, props: undefined };

@@ -488,9 +488,9 @@ subschemaCode(nextContext, valid);

else if (cxt.$data && def.validate) {
keyword_1.funcKeywordCode(cxt, def);
(0, keyword_1.funcKeywordCode)(cxt, def);
}
else if ("macro" in def) {
keyword_1.macroKeywordCode(cxt, def);
(0, keyword_1.macroKeywordCode)(cxt, def);
}
else if (def.compile || def.validate) {
keyword_1.funcKeywordCode(cxt, def);
(0, keyword_1.funcKeywordCode)(cxt, def);
}

@@ -532,4 +532,4 @@ }

if (segment) {
data = codegen_1._ `${data}${codegen_1.getProperty(util_1.unescapeJsonPointer(segment))}`;
expr = codegen_1._ `${expr} && ${data}`;
data = (0, codegen_1._) `${data}${(0, codegen_1.getProperty)((0, util_1.unescapeJsonPointer)(segment))}`;
expr = (0, codegen_1._) `${expr} && ${data}`;
}

@@ -536,0 +536,0 @@ }

@@ -50,7 +50,7 @@ "use strict";

const ruleErrs = gen.let("ruleErrs", null);
gen.try(() => assignValid(codegen_1._ `await `), (e) => gen.assign(valid, false).if(codegen_1._ `${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, codegen_1._ `${e}.errors`), () => gen.throw(e)));
gen.try(() => assignValid((0, codegen_1._) `await `), (e) => gen.assign(valid, false).if((0, codegen_1._) `${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_1._) `${e}.errors`), () => gen.throw(e)));
return ruleErrs;
}
function validateSync() {
const validateErrs = codegen_1._ `${validateRef}.errors`;
const validateErrs = (0, codegen_1._) `${validateRef}.errors`;
gen.assign(validateErrs, null);

@@ -60,10 +60,10 @@ assignValid(codegen_1.nil);

}
function assignValid(_await = def.async ? codegen_1._ `await ` : codegen_1.nil) {
function assignValid(_await = def.async ? (0, codegen_1._) `await ` : codegen_1.nil) {
const passCxt = it.opts.passContext ? names_1.default.this : names_1.default.self;
const passSchema = !(("compile" in def && !$data) || def.schema === false);
gen.assign(valid, codegen_1._ `${_await}${code_1.callValidateCode(cxt, validateRef, passCxt, passSchema)}`, def.modifying);
gen.assign(valid, (0, codegen_1._) `${_await}${(0, code_1.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def.modifying);
}
function reportErrs(errors) {
var _a;
gen.if(codegen_1.not((_a = def.valid) !== null && _a !== void 0 ? _a : valid), errors);
gen.if((0, codegen_1.not)((_a = def.valid) !== null && _a !== void 0 ? _a : valid), errors);
}

@@ -74,11 +74,11 @@ }

const { gen, data, it } = cxt;
gen.if(it.parentData, () => gen.assign(data, codegen_1._ `${it.parentData}[${it.parentDataProperty}]`));
gen.if(it.parentData, () => gen.assign(data, (0, codegen_1._) `${it.parentData}[${it.parentDataProperty}]`));
}
function addErrs(cxt, errs) {
const { gen } = cxt;
gen.if(codegen_1._ `Array.isArray(${errs})`, () => {
gen.if((0, codegen_1._) `Array.isArray(${errs})`, () => {
gen
.assign(names_1.default.vErrors, codegen_1._ `${names_1.default.vErrors} === null ? ${errs} : ${names_1.default.vErrors}.concat(${errs})`)
.assign(names_1.default.errors, codegen_1._ `${names_1.default.vErrors}.length`);
errors_1.extendErrors(cxt);
.assign(names_1.default.vErrors, (0, codegen_1._) `${names_1.default.vErrors} === null ? ${errs} : ${names_1.default.vErrors}.concat(${errs})`)
.assign(names_1.default.errors, (0, codegen_1._) `${names_1.default.vErrors}.length`);
(0, errors_1.extendErrors)(cxt);
}, () => cxt.error());

@@ -93,3 +93,3 @@ }

throw new Error(`keyword "${keyword}" failed to compile`);
return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: codegen_1.stringify(result) });
return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1.stringify)(result) });
}

@@ -96,0 +96,0 @@ function validSchemaType(schema, schemaType, allowUndefined = false) {

@@ -15,3 +15,3 @@ "use strict";

schema: sch,
schemaPath: codegen_1._ `${it.schemaPath}${codegen_1.getProperty(keyword)}`,
schemaPath: (0, codegen_1._) `${it.schemaPath}${(0, codegen_1.getProperty)(keyword)}`,
errSchemaPath: `${it.errSchemaPath}/${keyword}`,

@@ -21,4 +21,4 @@ }

schema: sch[schemaProp],
schemaPath: codegen_1._ `${it.schemaPath}${codegen_1.getProperty(keyword)}${codegen_1.getProperty(schemaProp)}`,
errSchemaPath: `${it.errSchemaPath}/${keyword}/${util_1.escapeFragment(schemaProp)}`,
schemaPath: (0, codegen_1._) `${it.schemaPath}${(0, codegen_1.getProperty)(keyword)}${(0, codegen_1.getProperty)(schemaProp)}`,
errSchemaPath: `${it.errSchemaPath}/${keyword}/${(0, util_1.escapeFragment)(schemaProp)}`,
};

@@ -47,6 +47,6 @@ }

const { errorPath, dataPathArr, opts } = it;
const nextData = gen.let("data", codegen_1._ `${it.data}${codegen_1.getProperty(dataProp)}`, true);
const nextData = gen.let("data", (0, codegen_1._) `${it.data}${(0, codegen_1.getProperty)(dataProp)}`, true);
dataContextProps(nextData);
subschema.errorPath = codegen_1.str `${errorPath}${util_1.getErrorPath(dataProp, dpType, opts.jsPropertySyntax)}`;
subschema.parentDataProperty = codegen_1._ `${dataProp}`;
subschema.errorPath = (0, codegen_1.str) `${errorPath}${(0, util_1.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
subschema.parentDataProperty = (0, codegen_1._) `${dataProp}`;
subschema.dataPathArr = [...dataPathArr, subschema.parentDataProperty];

@@ -53,0 +53,0 @@ }

@@ -101,3 +101,3 @@ "use strict";

opts.validateFormats = false;
this.RULES = rules_1.getRules();
this.RULES = (0, rules_1.getRules)();
checkOptions.call(this, removedOptions, opts, "NOT SUPPORTED");

@@ -227,3 +227,3 @@ checkOptions.call(this, deprecatedOptions, opts, "DEPRECATED", "warn");

}
key = resolve_1.normalizeId(key || id);
key = (0, resolve_1.normalizeId)(key || id);
this._checkUnique(key);

@@ -311,3 +311,3 @@ this.schemas[key] = this._addSchema(schema, _meta, key, _validateSchema, true);

if (id) {
id = resolve_1.normalizeId(id);
id = (0, resolve_1.normalizeId)(id);
delete this.schemas[id];

@@ -350,3 +350,3 @@ delete this.refs[id];

if (!def) {
util_1.eachItem(keyword, (kwd) => addRule.call(this, kwd));
(0, util_1.eachItem)(keyword, (kwd) => addRule.call(this, kwd));
return this;

@@ -357,6 +357,6 @@ }

...def,
type: dataType_1.getJSONTypes(def.type),
schemaType: dataType_1.getJSONTypes(def.schemaType),
type: (0, dataType_1.getJSONTypes)(def.type),
schemaType: (0, dataType_1.getJSONTypes)(def.schemaType),
};
util_1.eachItem(keyword, definition.type.length === 0
(0, util_1.eachItem)(keyword, definition.type.length === 0
? (k) => addRule.call(this, k, definition)

@@ -448,4 +448,4 @@ : (k) => definition.type.forEach((t) => addRule.call(this, k, definition, t)));

return sch;
const localRefs = resolve_1.getSchemaRefs.call(this, schema);
baseId = resolve_1.normalizeId(id || baseId);
baseId = (0, resolve_1.normalizeId)(id || baseId);
const localRefs = resolve_1.getSchemaRefs.call(this, schema, baseId);
sch = new compile_1.SchemaEnv({ schema, schemaId, meta, baseId, localRefs });

@@ -500,3 +500,3 @@ this._cache.set(sch.schema, sch);

function getSchEnv(keyRef) {
keyRef = resolve_1.normalizeId(keyRef); // TODO tests fail without this line
keyRef = (0, resolve_1.normalizeId)(keyRef); // TODO tests fail without this line
return this.schemas[keyRef] || this.refs[keyRef];

@@ -553,3 +553,3 @@ }

const { RULES } = this;
util_1.eachItem(keyword, (kwd) => {
(0, util_1.eachItem)(keyword, (kwd) => {
if (RULES.keywords[kwd])

@@ -584,4 +584,4 @@ throw new Error(`Keyword ${kwd} is already defined`);

...definition,
type: dataType_1.getJSONTypes(definition.type),
schemaType: dataType_1.getJSONTypes(definition.schemaType),
type: (0, dataType_1.getJSONTypes)(definition.type),
schemaType: (0, dataType_1.getJSONTypes)(definition.schemaType),
},

@@ -588,0 +588,0 @@ };

@@ -133,3 +133,8 @@ "use strict";

code <<= 4;
c = s[pos].toLowerCase();
c = s[pos];
if (c === undefined) {
errorMessage("unexpected end");
return undefined;
}
c = c.toLowerCase();
if (c >= "a" && c <= "f") {

@@ -141,6 +146,2 @@ code += c.charCodeAt(0) - CODE_A + 10;

}
else if (c === undefined) {
errorMessage("unexpected end");
return undefined;
}
else {

@@ -158,2 +159,3 @@ errorMessage(`unexpected token ${c}`);

}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
}

@@ -160,0 +162,0 @@ else if (c === undefined) {

import type AjvCore from "../core";
import type { AnyValidateFunction } from "../types";
export default function standaloneCode(ajv: AjvCore, refsOrFunc?: {
declare function standaloneCode(ajv: AjvCore, refsOrFunc?: {
[K in string]?: string;
} | AnyValidateFunction): string;
export default standaloneCode;

@@ -30,3 +30,3 @@ "use strict";

const usedValues = {};
let code = code_1._ `"use strict";`;
let code = (0, code_1._) `"use strict";`;
for (const name in schemas) {

@@ -36,3 +36,3 @@ const v = getValidateFunc(schemas[name]);

const vCode = validateCode(usedValues, v.source);
code = code_1._ `${code}${_n}exports${code_1.getProperty(name)} = ${(_a = v.source) === null || _a === void 0 ? void 0 : _a.validateName};${_n}${vCode}`;
code = (0, code_1._) `${code}${_n}exports${(0, code_1.getProperty)(name)} = ${(_a = v.source) === null || _a === void 0 ? void 0 : _a.validateName};${_n}${vCode}`;
}

@@ -50,3 +50,3 @@ }

const code = new code_1._Code(`${scopeCode}${_n}${s.validateCode}`);
return s.evaluated ? code_1._ `${code}${s.validateName}.evaluated = ${s.evaluated};${_n}` : code;
return s.evaluated ? (0, code_1._) `${code}${s.validateName}.evaluated = ${s.evaluated};${_n}` : code;
function refValidateCode(n) {

@@ -64,7 +64,7 @@ var _a;

const def = ajv.opts.code.es5 ? scope_1.varKinds.var : scope_1.varKinds.const;
const wrapper = code_1._ `${def} ${n} = {validate: ${validateName}};`;
const wrapper = (0, code_1._) `${def} ${n} = {validate: ${validateName}};`;
if (usedState(validateName) === scope_1.UsedValueState.Started)
return wrapper;
const vCode = validateCode(usedValues, validate === null || validate === void 0 ? void 0 : validate.source);
return code_1._ `${wrapper}${_n}${vCode}`;
return (0, code_1._) `${wrapper}${_n}${vCode}`;
}

@@ -84,3 +84,5 @@ return undefined;

}
module.exports = exports = standaloneCode;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = standaloneCode;
//# sourceMappingURL=index.js.map

@@ -23,3 +23,3 @@ "use strict";

getStandalone(v) {
return requireFromString(_1.default(this.ajv, v));
return requireFromString((0, _1.default)(this.ajv, v));
}

@@ -26,0 +26,0 @@ addSchema(...args) {

declare type StrictNullChecksWrapper<Name extends string, Type> = undefined extends null ? `strictNullChecks must be true in tsconfig to use ${Name}` : Type;
declare type UnionToIntersection<U> = (U extends any ? (_: U) => void : never) extends (_: infer I) => void ? I : never;
export declare type SomeJSONSchema = UncheckedJSONSchemaType<Known, true>;

@@ -26,4 +27,4 @@ declare type UncheckedPartialSchema<T> = Partial<UncheckedJSONSchemaType<T, true>>;

} | ({
type: (T extends number ? JSONType<"number" | "integer", IsPartial> : T extends string ? JSONType<"string", IsPartial> : T extends boolean ? JSONType<"boolean", IsPartial> : never)[];
} & (T extends number ? NumberKeywords : T extends string ? StringKeywords : T extends boolean ? unknown : never)) | ((T extends number ? {
type: readonly (T extends number ? JSONType<"number" | "integer", IsPartial> : T extends string ? JSONType<"string", IsPartial> : T extends boolean ? JSONType<"boolean", IsPartial> : never)[];
} & UnionToIntersection<T extends number ? NumberKeywords : T extends string ? StringKeywords : T extends boolean ? {} : never>) | ((T extends number ? {
type: JSONType<"number" | "integer", IsPartial>;

@@ -33,4 +34,4 @@ } & NumberKeywords : T extends string ? {

} & StringKeywords : T extends boolean ? {
type: "boolean";
} : T extends [any, ...any[]] ? {
type: JSONType<"boolean", IsPartial>;
} : T extends readonly [any, ...any[]] ? {
type: JSONType<"array", IsPartial>;

@@ -62,5 +63,3 @@ items: {

properties?: IsPartial extends true ? Partial<UncheckedPropertiesSchema<T>> : UncheckedPropertiesSchema<T>;
patternProperties?: {
[Pattern in string]?: UncheckedJSONSchemaType<T[string], false>;
};
patternProperties?: Record<string, UncheckedJSONSchemaType<T[string], false>>;
propertyNames?: Omit<UncheckedJSONSchemaType<string, false>, "type"> & {

@@ -87,2 +86,3 @@ type?: "string";

}) : T extends null ? {
type: JSONType<"null", IsPartial>;
nullable: true;

@@ -101,13 +101,9 @@ } : never) & {

$ref?: string;
$defs?: {
[Key in string]?: UncheckedJSONSchemaType<Known, true>;
};
definitions?: {
[Key in string]?: UncheckedJSONSchemaType<Known, true>;
};
$defs?: Record<string, UncheckedJSONSchemaType<Known, true>>;
definitions?: Record<string, UncheckedJSONSchemaType<Known, true>>;
};
export declare type JSONSchemaType<T> = StrictNullChecksWrapper<"JSONSchemaType", UncheckedJSONSchemaType<T, false>>;
declare type Known = KnownRecord | [Known, ...Known[]] | Known[] | number | string | boolean | null;
interface KnownRecord extends Record<string, Known> {
}
declare type Known = {
[key: string]: Known;
} | [Known, ...Known[]] | Known[] | number | string | boolean | null;
declare type UncheckedPropertiesSchema<T> = {

@@ -125,3 +121,3 @@ [K in keyof T]-?: (UncheckedJSONSchemaType<T[K], false> & Nullable<T[K]>) | {

nullable: true;
const?: never;
const?: null;
enum?: Readonly<(T | null)[]>;

@@ -128,0 +124,0 @@ default?: T | null;

@@ -7,4 +7,4 @@ "use strict";

const error = {
message: ({ params: { len } }) => codegen_1.str `must NOT have more than ${len} items`,
params: ({ params: { len } }) => codegen_1._ `{limit: ${len}}`,
message: ({ params: { len } }) => (0, codegen_1.str) `must NOT have more than ${len} items`,
params: ({ params: { len } }) => (0, codegen_1._) `{limit: ${len}}`,
};

@@ -21,3 +21,3 @@ const def = {

if (!Array.isArray(items)) {
util_1.checkStrictMode(it, '"additionalItems" is ignored when "items" is not an array of schemas');
(0, util_1.checkStrictMode)(it, '"additionalItems" is ignored when "items" is not an array of schemas');
return;

@@ -31,10 +31,10 @@ }

it.items = true;
const len = gen.const("len", codegen_1._ `${data}.length`);
const len = gen.const("len", (0, codegen_1._) `${data}.length`);
if (schema === false) {
cxt.setParams({ len: items.length });
cxt.pass(codegen_1._ `${len} <= ${items.length}`);
cxt.pass((0, codegen_1._) `${len} <= ${items.length}`);
}
else if (typeof schema == "object" && !util_1.alwaysValidSchema(it, schema)) {
const valid = gen.var("valid", codegen_1._ `${len} <= ${items.length}`); // TODO var
gen.if(codegen_1.not(valid), () => validateItems(valid));
else if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) {
const valid = gen.var("valid", (0, codegen_1._) `${len} <= ${items.length}`); // TODO var
gen.if((0, codegen_1.not)(valid), () => validateItems(valid));
cxt.ok(valid);

@@ -46,3 +46,3 @@ }

if (!it.allErrors)
gen.if(codegen_1.not(valid), () => gen.break());
gen.if((0, codegen_1.not)(valid), () => gen.break());
});

@@ -49,0 +49,0 @@ }

@@ -9,3 +9,3 @@ "use strict";

message: "must NOT have additional properties",
params: ({ params }) => codegen_1._ `{additionalProperty: ${params.additionalProperty}}`,
params: ({ params }) => (0, codegen_1._) `{additionalProperty: ${params.additionalProperty}}`,
};

@@ -26,8 +26,8 @@ const def = {

it.props = true;
if (opts.removeAdditional !== "all" && util_1.alwaysValidSchema(it, schema))
if (opts.removeAdditional !== "all" && (0, util_1.alwaysValidSchema)(it, schema))
return;
const props = code_1.allSchemaProperties(parentSchema.properties);
const patProps = code_1.allSchemaProperties(parentSchema.patternProperties);
const props = (0, code_1.allSchemaProperties)(parentSchema.properties);
const patProps = (0, code_1.allSchemaProperties)(parentSchema.patternProperties);
checkAdditionalProperties();
cxt.ok(codegen_1._ `${errsCount} === ${names_1.default.errors}`);
cxt.ok((0, codegen_1._) `${errsCount} === ${names_1.default.errors}`);
function checkAdditionalProperties() {

@@ -45,7 +45,7 @@ gen.forIn("key", data, (key) => {

// TODO maybe an option instead of hard-coded 8?
const propsSchema = util_1.schemaRefOrVal(it, parentSchema.properties, "properties");
definedProp = code_1.isOwnProperty(gen, propsSchema, key);
const propsSchema = (0, util_1.schemaRefOrVal)(it, parentSchema.properties, "properties");
definedProp = (0, code_1.isOwnProperty)(gen, propsSchema, key);
}
else if (props.length) {
definedProp = codegen_1.or(...props.map((p) => codegen_1._ `${key} === ${p}`));
definedProp = (0, codegen_1.or)(...props.map((p) => (0, codegen_1._) `${key} === ${p}`));
}

@@ -56,8 +56,8 @@ else {

if (patProps.length) {
definedProp = codegen_1.or(definedProp, ...patProps.map((p) => codegen_1._ `${code_1.usePattern(cxt, p)}.test(${key})`));
definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((p) => (0, codegen_1._) `${(0, code_1.usePattern)(cxt, p)}.test(${key})`));
}
return codegen_1.not(definedProp);
return (0, codegen_1.not)(definedProp);
}
function deleteAdditional(key) {
gen.code(codegen_1._ `delete ${data}[${key}]`);
gen.code((0, codegen_1._) `delete ${data}[${key}]`);
}

@@ -76,7 +76,7 @@ function additionalPropertyCode(key) {

}
if (typeof schema == "object" && !util_1.alwaysValidSchema(it, schema)) {
if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) {
const valid = gen.name("valid");
if (opts.removeAdditional === "failing") {
applyAdditionalSchema(key, valid, false);
gen.if(codegen_1.not(valid), () => {
gen.if((0, codegen_1.not)(valid), () => {
cxt.reset();

@@ -89,3 +89,3 @@ deleteAdditional(key);

if (!allErrors)
gen.if(codegen_1.not(valid), () => gen.break());
gen.if((0, codegen_1.not)(valid), () => gen.break());
}

@@ -92,0 +92,0 @@ }

@@ -14,3 +14,3 @@ "use strict";

schema.forEach((sch, i) => {
if (util_1.alwaysValidSchema(it, sch))
if ((0, util_1.alwaysValidSchema)(it, sch))
return;

@@ -17,0 +17,0 @@ const schCxt = cxt.subschema({ keyword: "allOf", schemaProp: i }, valid);

@@ -7,5 +7,5 @@ "use strict";

message: ({ params: { min, max } }) => max === undefined
? codegen_1.str `must contain at least ${min} valid item(s)`
: codegen_1.str `must contain at least ${min} and no more than ${max} valid item(s)`,
params: ({ params: { min, max } }) => max === undefined ? codegen_1._ `{minContains: ${min}}` : codegen_1._ `{minContains: ${min}, maxContains: ${max}}`,
? (0, codegen_1.str) `must contain at least ${min} valid item(s)`
: (0, codegen_1.str) `must contain at least ${min} and no more than ${max} valid item(s)`,
params: ({ params: { min, max } }) => max === undefined ? (0, codegen_1._) `{minContains: ${min}}` : (0, codegen_1._) `{minContains: ${min}, maxContains: ${max}}`,
};

@@ -31,17 +31,17 @@ const def = {

}
const len = gen.const("len", codegen_1._ `${data}.length`);
const len = gen.const("len", (0, codegen_1._) `${data}.length`);
cxt.setParams({ min, max });
if (max === undefined && min === 0) {
util_1.checkStrictMode(it, `"minContains" == 0 without "maxContains": "contains" keyword ignored`);
(0, util_1.checkStrictMode)(it, `"minContains" == 0 without "maxContains": "contains" keyword ignored`);
return;
}
if (max !== undefined && min > max) {
util_1.checkStrictMode(it, `"minContains" > "maxContains" is always invalid`);
(0, util_1.checkStrictMode)(it, `"minContains" > "maxContains" is always invalid`);
cxt.fail();
return;
}
if (util_1.alwaysValidSchema(it, schema)) {
let cond = codegen_1._ `${len} >= ${min}`;
if ((0, util_1.alwaysValidSchema)(it, schema)) {
let cond = (0, codegen_1._) `${len} >= ${min}`;
if (max !== undefined)
cond = codegen_1._ `${cond} && ${len} <= ${max}`;
cond = (0, codegen_1._) `${cond} && ${len} <= ${max}`;
cxt.pass(cond);

@@ -74,12 +74,12 @@ return;

function checkLimits(count) {
gen.code(codegen_1._ `${count}++`);
gen.code((0, codegen_1._) `${count}++`);
if (max === undefined) {
gen.if(codegen_1._ `${count} >= ${min}`, () => gen.assign(valid, true).break());
gen.if((0, codegen_1._) `${count} >= ${min}`, () => gen.assign(valid, true).break());
}
else {
gen.if(codegen_1._ `${count} > ${max}`, () => gen.assign(valid, false).break());
gen.if((0, codegen_1._) `${count} > ${max}`, () => gen.assign(valid, false).break());
if (min === 1)
gen.assign(valid, true);
else
gen.if(codegen_1._ `${count} >= ${min}`, () => gen.assign(valid, true));
gen.if((0, codegen_1._) `${count} >= ${min}`, () => gen.assign(valid, true));
}

@@ -86,0 +86,0 @@ }

@@ -10,5 +10,5 @@ "use strict";

const property_ies = depsCount === 1 ? "property" : "properties";
return codegen_1.str `must have ${property_ies} ${deps} when property ${property} is present`;
return (0, codegen_1.str) `must have ${property_ies} ${deps} when property ${property} is present`;
},
params: ({ params: { property, depsCount, deps, missingProperty } }) => codegen_1._ `{property: ${property},
params: ({ params: { property, depsCount, deps, missingProperty } }) => (0, codegen_1._) `{property: ${property},
missingProperty: ${missingProperty},

@@ -49,3 +49,3 @@ depsCount: ${depsCount},

continue;
const hasProperty = code_1.propertyInData(gen, data, prop, it.opts.ownProperties);
const hasProperty = (0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties);
cxt.setParams({

@@ -59,3 +59,3 @@ property: prop,

for (const depProp of deps) {
code_1.checkReportMissingProp(cxt, depProp);
(0, code_1.checkReportMissingProp)(cxt, depProp);
}

@@ -65,4 +65,4 @@ });

else {
gen.if(codegen_1._ `${hasProperty} && (${code_1.checkMissingProp(cxt, deps, missing)})`);
code_1.reportMissingProp(cxt, missing);
gen.if((0, codegen_1._) `${hasProperty} && (${(0, code_1.checkMissingProp)(cxt, deps, missing)})`);
(0, code_1.reportMissingProp)(cxt, missing);
gen.else();

@@ -77,5 +77,5 @@ }

for (const prop in schemaDeps) {
if (util_1.alwaysValidSchema(it, schemaDeps[prop]))
if ((0, util_1.alwaysValidSchema)(it, schemaDeps[prop]))
continue;
gen.if(code_1.propertyInData(gen, data, prop, it.opts.ownProperties), () => {
gen.if((0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties), () => {
const schCxt = cxt.subschema({ keyword, schemaProp: prop }, valid);

@@ -82,0 +82,0 @@ cxt.mergeValidEvaluated(schCxt, valid);

@@ -8,5 +8,5 @@ "use strict";

schemaType: "object",
code: (cxt) => dependencies_1.validateSchemaDeps(cxt),
code: (cxt) => (0, dependencies_1.validateSchemaDeps)(cxt),
};
exports.default = def;
//# sourceMappingURL=dependentSchemas.js.map

@@ -6,4 +6,4 @@ "use strict";

const error = {
message: ({ params }) => codegen_1.str `must match "${params.ifClause}" schema`,
params: ({ params }) => codegen_1._ `{failingKeyword: ${params.ifClause}}`,
message: ({ params }) => (0, codegen_1.str) `must match "${params.ifClause}" schema`,
params: ({ params }) => (0, codegen_1._) `{failingKeyword: ${params.ifClause}}`,
};

@@ -18,3 +18,3 @@ const def = {

if (parentSchema.then === undefined && parentSchema.else === undefined) {
util_1.checkStrictMode(it, '"if" without "then" and "else" is ignored');
(0, util_1.checkStrictMode)(it, '"if" without "then" and "else" is ignored');
}

@@ -38,3 +38,3 @@ const hasThen = hasSchema(it, "then");

else {
gen.if(codegen_1.not(schValid), validateClause("else"));
gen.if((0, codegen_1.not)(schValid), validateClause("else"));
}

@@ -57,3 +57,3 @@ cxt.pass(valid, () => cxt.error(true));

if (ifClause)
gen.assign(ifClause, codegen_1._ `${keyword}`);
gen.assign(ifClause, (0, codegen_1._) `${keyword}`);
else

@@ -67,5 +67,5 @@ cxt.setParams({ ifClause: keyword });

const schema = it.schema[keyword];
return schema !== undefined && !util_1.alwaysValidSchema(it, schema);
return schema !== undefined && !(0, util_1.alwaysValidSchema)(it, schema);
}
exports.default = def;
//# sourceMappingURL=if.js.map

@@ -17,5 +17,5 @@ "use strict";

it.items = true;
if (util_1.alwaysValidSchema(it, schema))
if ((0, util_1.alwaysValidSchema)(it, schema))
return;
cxt.ok(code_1.validateArray(cxt));
cxt.ok((0, code_1.validateArray)(cxt));
},

@@ -30,7 +30,7 @@ };

const valid = gen.name("valid");
const len = gen.const("len", codegen_1._ `${data}.length`);
const len = gen.const("len", (0, codegen_1._) `${data}.length`);
schArr.forEach((sch, i) => {
if (util_1.alwaysValidSchema(it, sch))
if ((0, util_1.alwaysValidSchema)(it, sch))
return;
gen.if(codegen_1._ `${len} > ${i}`, () => cxt.subschema({
gen.if((0, codegen_1._) `${len} > ${i}`, () => cxt.subschema({
keyword,

@@ -48,3 +48,3 @@ schemaProp: i,

const msg = `"${keyword}" is ${l}-tuple, but minItems or maxItems/${extraItems} are not specified or different at path "${errSchemaPath}"`;
util_1.checkStrictMode(it, msg, opts.strictTuples);
(0, util_1.checkStrictMode)(it, msg, opts.strictTuples);
}

@@ -51,0 +51,0 @@ }

@@ -8,4 +8,4 @@ "use strict";

const error = {
message: ({ params: { len } }) => codegen_1.str `must NOT have more than ${len} items`,
params: ({ params: { len } }) => codegen_1._ `{limit: ${len}}`,
message: ({ params: { len } }) => (0, codegen_1.str) `must NOT have more than ${len} items`,
params: ({ params: { len } }) => (0, codegen_1._) `{limit: ${len}}`,
};

@@ -22,8 +22,8 @@ const def = {

it.items = true;
if (util_1.alwaysValidSchema(it, schema))
if ((0, util_1.alwaysValidSchema)(it, schema))
return;
if (prefixItems)
additionalItems_1.validateAdditionalItems(cxt, prefixItems);
(0, additionalItems_1.validateAdditionalItems)(cxt, prefixItems);
else
cxt.ok(code_1.validateArray(cxt));
cxt.ok((0, code_1.validateArray)(cxt));
},

@@ -30,0 +30,0 @@ };

@@ -10,3 +10,3 @@ "use strict";

const { gen, schema, it } = cxt;
if (util_1.alwaysValidSchema(it, schema)) {
if ((0, util_1.alwaysValidSchema)(it, schema)) {
cxt.fail();

@@ -13,0 +13,0 @@ return;

@@ -7,3 +7,3 @@ "use strict";

message: "must match exactly one schema in oneOf",
params: ({ params }) => codegen_1._ `{passingSchemas: ${params.passing}}`,
params: ({ params }) => (0, codegen_1._) `{passingSchemas: ${params.passing}}`,
};

@@ -33,3 +33,3 @@ const def = {

let schCxt;
if (util_1.alwaysValidSchema(it, sch)) {
if ((0, util_1.alwaysValidSchema)(it, sch)) {
gen.var(schValid, true);

@@ -46,5 +46,5 @@ }

gen
.if(codegen_1._ `${schValid} && ${valid}`)
.if((0, codegen_1._) `${schValid} && ${valid}`)
.assign(valid, false)
.assign(passing, codegen_1._ `[${passing}, ${i}]`)
.assign(passing, (0, codegen_1._) `[${passing}, ${i}]`)
.else();

@@ -51,0 +51,0 @@ }

@@ -14,4 +14,4 @@ "use strict";

const { opts } = it;
const patterns = code_1.allSchemaProperties(schema);
const alwaysValidPatterns = patterns.filter((p) => util_1.alwaysValidSchema(it, schema[p]));
const patterns = (0, code_1.allSchemaProperties)(schema);
const alwaysValidPatterns = patterns.filter((p) => (0, util_1.alwaysValidSchema)(it, schema[p]));
if (patterns.length === 0 ||

@@ -25,3 +25,3 @@ (alwaysValidPatterns.length === patterns.length &&

if (it.props !== true && !(it.props instanceof codegen_1.Name)) {
it.props = util_2.evaluatedPropsToName(gen, it.props);
it.props = (0, util_2.evaluatedPropsToName)(gen, it.props);
}

@@ -47,3 +47,3 @@ const { props } = it;

if (new RegExp(pat).test(prop)) {
util_1.checkStrictMode(it, `property ${prop} matches pattern ${pat} (use allowMatchingProperties)`);
(0, util_1.checkStrictMode)(it, `property ${prop} matches pattern ${pat} (use allowMatchingProperties)`);
}

@@ -54,3 +54,3 @@ }

gen.forIn("key", data, (key) => {
gen.if(codegen_1._ `${code_1.usePattern(cxt, pat)}.test(${key})`, () => {
gen.if((0, codegen_1._) `${(0, code_1.usePattern)(cxt, pat)}.test(${key})`, () => {
const alwaysValid = alwaysValidPatterns.includes(pat);

@@ -66,3 +66,3 @@ if (!alwaysValid) {

if (it.opts.unevaluated && props !== true) {
gen.assign(codegen_1._ `${props}[${key}]`, true);
gen.assign((0, codegen_1._) `${props}[${key}]`, true);
}

@@ -72,3 +72,3 @@ else if (!alwaysValid && !it.allErrors) {

// or if all properties were evaluated (props === true)
gen.if(codegen_1.not(valid), () => gen.break());
gen.if((0, codegen_1.not)(valid), () => gen.break());
}

@@ -75,0 +75,0 @@ });

@@ -9,5 +9,5 @@ "use strict";

before: "uniqueItems",
code: (cxt) => items_1.validateTuple(cxt, "items"),
code: (cxt) => (0, items_1.validateTuple)(cxt, "items"),
};
exports.default = def;
//# sourceMappingURL=prefixItems.js.map

@@ -16,3 +16,3 @@ "use strict";

}
const allProps = code_1.allSchemaProperties(schema);
const allProps = (0, code_1.allSchemaProperties)(schema);
for (const prop of allProps) {

@@ -22,5 +22,5 @@ it.definedProperties.add(prop);

if (it.opts.unevaluated && allProps.length && it.props !== true) {
it.props = util_1.mergeEvaluated.props(gen, util_1.toHash(allProps), it.props);
it.props = util_1.mergeEvaluated.props(gen, (0, util_1.toHash)(allProps), it.props);
}
const properties = allProps.filter((p) => !util_1.alwaysValidSchema(it, schema[p]));
const properties = allProps.filter((p) => !(0, util_1.alwaysValidSchema)(it, schema[p]));
if (properties.length === 0)

@@ -34,3 +34,3 @@ return;

else {
gen.if(code_1.propertyInData(gen, data, prop, it.opts.ownProperties));
gen.if((0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties));
applyPropertySchema(prop);

@@ -37,0 +37,0 @@ if (!it.allErrors)

@@ -7,3 +7,3 @@ "use strict";

message: "property name must be valid",
params: ({ params }) => codegen_1._ `{propertyName: ${params.propertyName}}`,
params: ({ params }) => (0, codegen_1._) `{propertyName: ${params.propertyName}}`,
};

@@ -17,3 +17,3 @@ const def = {

const { gen, schema, data, it } = cxt;
if (util_1.alwaysValidSchema(it, schema))
if ((0, util_1.alwaysValidSchema)(it, schema))
return;

@@ -30,3 +30,3 @@ const valid = gen.name("valid");

}, valid);
gen.if(codegen_1.not(valid), () => {
gen.if((0, codegen_1.not)(valid), () => {
cxt.error(true);

@@ -33,0 +33,0 @@ if (!it.allErrors)

@@ -9,3 +9,3 @@ "use strict";

if (parentSchema.if === undefined)
util_1.checkStrictMode(it, `"${keyword}" without "if" is ignored`);
(0, util_1.checkStrictMode)(it, `"${keyword}" without "if" is ignored`);
},

@@ -12,0 +12,0 @@ };

@@ -10,3 +10,3 @@ "use strict";

gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
cxt.setParams({ missingProperty: codegen_1._ `${prop}` }, true);
cxt.setParams({ missingProperty: (0, codegen_1._) `${prop}` }, true);
cxt.error();

@@ -17,3 +17,3 @@ });

function checkMissingProp({ gen, data, it: { opts } }, properties, missing) {
return codegen_1.or(...properties.map((prop) => codegen_1.and(noPropertyInData(gen, data, prop, opts.ownProperties), codegen_1._ `${missing} = ${prop}`)));
return (0, codegen_1.or)(...properties.map((prop) => (0, codegen_1.and)(noPropertyInData(gen, data, prop, opts.ownProperties), (0, codegen_1._) `${missing} = ${prop}`)));
}

@@ -30,3 +30,3 @@ exports.checkMissingProp = checkMissingProp;

ref: Object.prototype.hasOwnProperty,
code: codegen_1._ `Object.prototype.hasOwnProperty`,
code: (0, codegen_1._) `Object.prototype.hasOwnProperty`,
});

@@ -36,13 +36,13 @@ }

function isOwnProperty(gen, data, property) {
return codegen_1._ `${hasPropFunc(gen)}.call(${data}, ${property})`;
return (0, codegen_1._) `${hasPropFunc(gen)}.call(${data}, ${property})`;
}
exports.isOwnProperty = isOwnProperty;
function propertyInData(gen, data, property, ownProperties) {
const cond = codegen_1._ `${data}${codegen_1.getProperty(property)} !== undefined`;
return ownProperties ? codegen_1._ `${cond} && ${isOwnProperty(gen, data, property)}` : cond;
const cond = (0, codegen_1._) `${data}${(0, codegen_1.getProperty)(property)} !== undefined`;
return ownProperties ? (0, codegen_1._) `${cond} && ${isOwnProperty(gen, data, property)}` : cond;
}
exports.propertyInData = propertyInData;
function noPropertyInData(gen, data, property, ownProperties) {
const cond = codegen_1._ `${data}${codegen_1.getProperty(property)} === undefined`;
return ownProperties ? codegen_1.or(cond, codegen_1.not(isOwnProperty(gen, data, property))) : cond;
const cond = (0, codegen_1._) `${data}${(0, codegen_1.getProperty)(property)} === undefined`;
return ownProperties ? (0, codegen_1.or)(cond, (0, codegen_1.not)(isOwnProperty(gen, data, property))) : cond;
}

@@ -55,9 +55,9 @@ exports.noPropertyInData = noPropertyInData;

function schemaProperties(it, schemaMap) {
return allSchemaProperties(schemaMap).filter((p) => !util_1.alwaysValidSchema(it, schemaMap[p]));
return allSchemaProperties(schemaMap).filter((p) => !(0, util_1.alwaysValidSchema)(it, schemaMap[p]));
}
exports.schemaProperties = schemaProperties;
function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
const dataAndSchema = passSchema ? codegen_1._ `${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
const dataAndSchema = passSchema ? (0, codegen_1._) `${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
const valCxt = [
[names_1.default.instancePath, codegen_1.strConcat(names_1.default.instancePath, errorPath)],
[names_1.default.instancePath, (0, codegen_1.strConcat)(names_1.default.instancePath, errorPath)],
[names_1.default.parentData, it.parentData],

@@ -69,4 +69,4 @@ [names_1.default.parentDataProperty, it.parentDataProperty],

valCxt.push([names_1.default.dynamicAnchors, names_1.default.dynamicAnchors]);
const args = codegen_1._ `${dataAndSchema}, ${gen.object(...valCxt)}`;
return context !== codegen_1.nil ? codegen_1._ `${func}.call(${context}, ${args})` : codegen_1._ `${func}(${args})`;
const args = (0, codegen_1._) `${dataAndSchema}, ${gen.object(...valCxt)}`;
return context !== codegen_1.nil ? (0, codegen_1._) `${func}.call(${context}, ${args})` : (0, codegen_1._) `${func}(${args})`;
}

@@ -79,3 +79,3 @@ exports.callValidateCode = callValidateCode;

ref: new RegExp(pattern, u),
code: codegen_1._ `new RegExp(${pattern}, ${u})`,
code: (0, codegen_1._) `new RegExp(${pattern}, ${u})`,
});

@@ -96,3 +96,3 @@ }

function validateItems(notValid) {
const len = gen.const("len", codegen_1._ `${data}.length`);
const len = gen.const("len", (0, codegen_1._) `${data}.length`);
gen.forRange("i", 0, len, (i) => {

@@ -104,3 +104,3 @@ cxt.subschema({

}, valid);
gen.if(codegen_1.not(valid), notValid);
gen.if((0, codegen_1.not)(valid), notValid);
});

@@ -115,3 +115,3 @@ }

throw new Error("ajv implementation error");
const alwaysValid = schema.some((sch) => util_1.alwaysValidSchema(it, sch));
const alwaysValid = schema.some((sch) => (0, util_1.alwaysValidSchema)(it, sch));
if (alwaysValid && !it.opts.unevaluated)

@@ -127,3 +127,3 @@ return;

}, schValid);
gen.assign(valid, codegen_1._ `${valid} || ${schValid}`);
gen.assign(valid, (0, codegen_1._) `${valid} || ${schValid}`);
const merged = cxt.mergeValidEvaluated(schCxt, schValid);

@@ -133,3 +133,3 @@ // can short-circuit if `unevaluatedProperties/Items` not supported (opts.unevaluated !== true)

if (!merged)
gen.if(codegen_1.not(valid));
gen.if((0, codegen_1.not)(valid));
}));

@@ -136,0 +136,0 @@ cxt.result(valid, () => cxt.reset(), () => cxt.error(true));

@@ -29,3 +29,3 @@ "use strict";

const rootName = gen.scopeValue("root", { ref: root });
return callRef(cxt, codegen_1._ `${rootName}.validate`, root, root.$async);
return callRef(cxt, (0, codegen_1._) `${rootName}.validate`, root, root.$async);
}

@@ -37,3 +37,3 @@ function callValidate(sch) {

function inlineRefSchema(sch) {
const schName = gen.scopeValue("schema", opts.code.source === true ? { ref: sch, code: codegen_1.stringify(sch) } : { ref: sch });
const schName = gen.scopeValue("schema", opts.code.source === true ? { ref: sch, code: (0, codegen_1.stringify)(sch) } : { ref: sch });
const valid = gen.name("valid");

@@ -56,3 +56,3 @@ const schCxt = cxt.subschema({

? gen.scopeValue("validate", { ref: sch.validate })
: codegen_1._ `${gen.scopeValue("wrapper", { ref: sch })}.validate`;
: (0, codegen_1._) `${gen.scopeValue("wrapper", { ref: sch })}.validate`;
}

@@ -73,3 +73,3 @@ exports.getValidate = getValidate;

gen.try(() => {
gen.code(codegen_1._ `await ${code_1.callValidateCode(cxt, v, passCxt)}`);
gen.code((0, codegen_1._) `await ${(0, code_1.callValidateCode)(cxt, v, passCxt)}`);
addEvaluatedFrom(v); // TODO will not work with async, it has to be returned with the result

@@ -79,3 +79,3 @@ if (!allErrors)

}, (e) => {
gen.if(codegen_1._ `!(${e} instanceof ${it.ValidationError})`, () => gen.throw(e));
gen.if((0, codegen_1._) `!(${e} instanceof ${it.ValidationError})`, () => gen.throw(e));
addErrorsFrom(e);

@@ -88,8 +88,8 @@ if (!allErrors)

function callSyncRef() {
cxt.result(code_1.callValidateCode(cxt, v, passCxt), () => addEvaluatedFrom(v), () => addErrorsFrom(v));
cxt.result((0, code_1.callValidateCode)(cxt, v, passCxt), () => addEvaluatedFrom(v), () => addErrorsFrom(v));
}
function addErrorsFrom(source) {
const errs = codegen_1._ `${source}.errors`;
gen.assign(names_1.default.vErrors, codegen_1._ `${names_1.default.vErrors} === null ? ${errs} : ${names_1.default.vErrors}.concat(${errs})`); // TODO tagged
gen.assign(names_1.default.errors, codegen_1._ `${names_1.default.vErrors}.length`);
const errs = (0, codegen_1._) `${source}.errors`;
gen.assign(names_1.default.vErrors, (0, codegen_1._) `${names_1.default.vErrors} === null ? ${errs} : ${names_1.default.vErrors}.concat(${errs})`); // TODO tagged
gen.assign(names_1.default.errors, (0, codegen_1._) `${names_1.default.vErrors}.length`);
}

@@ -109,3 +109,3 @@ function addEvaluatedFrom(source) {

else {
const props = gen.var("props", codegen_1._ `${source}.evaluated.props`);
const props = gen.var("props", (0, codegen_1._) `${source}.evaluated.props`);
it.props = util_1.mergeEvaluated.props(gen, props, it.props, codegen_1.Name);

@@ -121,3 +121,3 @@ }

else {
const items = gen.var("items", codegen_1._ `${source}.evaluated.items`);
const items = gen.var("items", (0, codegen_1._) `${source}.evaluated.items`);
it.items = util_1.mergeEvaluated.items(gen, items, it.items, codegen_1.Name);

@@ -124,0 +124,0 @@ }

@@ -9,3 +9,3 @@ "use strict";

: `value of tag "${tagName}" must be in oneOf`,
params: ({ params: { discrError, tag, tagName } }) => codegen_1._ `{error: ${discrError}, tag: ${tagName}, tagValue: ${tag}}`,
params: ({ params: { discrError, tag, tagName } }) => (0, codegen_1._) `{error: ${discrError}, tag: ${tagName}, tagValue: ${tag}}`,
};

@@ -31,4 +31,4 @@ const def = {

const valid = gen.let("valid", false);
const tag = gen.const("tag", codegen_1._ `${data}${codegen_1.getProperty(tagName)}`);
gen.if(codegen_1._ `typeof ${tag} == "string"`, () => validateMapping(), () => cxt.error(false, { discrError: types_1.DiscrError.Tag, tag, tagName }));
const tag = gen.const("tag", (0, codegen_1._) `${data}${(0, codegen_1.getProperty)(tagName)}`);
gen.if((0, codegen_1._) `typeof ${tag} == "string"`, () => validateMapping(), () => cxt.error(false, { discrError: types_1.DiscrError.Tag, tag, tagName }));
cxt.ok(valid);

@@ -39,3 +39,3 @@ function validateMapping() {

for (const tagValue in mapping) {
gen.elseIf(codegen_1._ `${tag} === ${tagValue}`);
gen.elseIf((0, codegen_1._) `${tag} === ${tagValue}`);
gen.assign(valid, applyTagSchema(mapping[tagValue]));

@@ -42,0 +42,0 @@ }

@@ -15,3 +15,3 @@ "use strict";

validation_1.default,
applicator_1.default(true),
(0, applicator_1.default)(true),
format_1.default,

@@ -18,0 +18,0 @@ metadata_1.metadataVocabulary,

@@ -11,3 +11,3 @@ "use strict";

validation_1.default,
applicator_1.default(),
(0, applicator_1.default)(),
format_1.default,

@@ -14,0 +14,0 @@ metadata_1.metadataVocabulary,

@@ -16,5 +16,5 @@ "use strict";

it.schemaEnv.root.dynamicAnchors[anchor] = true;
const v = codegen_1._ `${names_1.default.dynamicAnchors}${codegen_1.getProperty(anchor)}`;
const v = (0, codegen_1._) `${names_1.default.dynamicAnchors}${(0, codegen_1.getProperty)(anchor)}`;
const validate = it.errSchemaPath === "#" ? it.validateName : _getValidate(cxt);
gen.if(codegen_1._ `!${v}`, () => gen.assign(v, validate));
gen.if((0, codegen_1._) `!${v}`, () => gen.assign(v, validate));
}

@@ -28,5 +28,5 @@ exports.dynamicAnchor = dynamicAnchor;

compile_1.compileSchema.call(self, sch);
return ref_1.getValidate(cxt, sch);
return (0, ref_1.getValidate)(cxt, sch);
}
exports.default = def;
//# sourceMappingURL=dynamicAnchor.js.map

@@ -33,3 +33,3 @@ "use strict";

if (it.schemaEnv.root.dynamicAnchors[anchor]) {
const v = gen.let("_v", codegen_1._ `${names_1.default.dynamicAnchors}${codegen_1.getProperty(anchor)}`);
const v = gen.let("_v", (0, codegen_1._) `${names_1.default.dynamicAnchors}${(0, codegen_1.getProperty)(anchor)}`);
gen.if(v, _callRef(v, valid), _callRef(it.validateName, valid));

@@ -44,6 +44,6 @@ }

? () => gen.block(() => {
ref_1.callRef(cxt, validate);
(0, ref_1.callRef)(cxt, validate);
gen.let(valid, true);
})
: () => ref_1.callRef(cxt, validate);
: () => (0, ref_1.callRef)(cxt, validate);
}

@@ -50,0 +50,0 @@ }

@@ -10,5 +10,5 @@ "use strict";

if (cxt.schema)
dynamicAnchor_1.dynamicAnchor(cxt, "");
(0, dynamicAnchor_1.dynamicAnchor)(cxt, "");
else
util_1.checkStrictMode(cxt.it, "$recursiveAnchor: false is ignored");
(0, util_1.checkStrictMode)(cxt.it, "$recursiveAnchor: false is ignored");
},

@@ -15,0 +15,0 @@ };

@@ -7,5 +7,5 @@ "use strict";

schemaType: "string",
code: (cxt) => dynamicRef_1.dynamicRef(cxt, cxt.schema),
code: (cxt) => (0, dynamicRef_1.dynamicRef)(cxt, cxt.schema),
};
exports.default = def;
//# sourceMappingURL=recursiveRef.js.map

@@ -5,4 +5,4 @@ "use strict";

const error = {
message: ({ schemaCode }) => codegen_1.str `must match format "${schemaCode}"`,
params: ({ schemaCode }) => codegen_1._ `{format: ${schemaCode}}`,
message: ({ schemaCode }) => (0, codegen_1.str) `must match format "${schemaCode}"`,
params: ({ schemaCode }) => (0, codegen_1._) `{format: ${schemaCode}}`,
};

@@ -29,19 +29,19 @@ const def = {

});
const fDef = gen.const("fDef", codegen_1._ `${fmts}[${schemaCode}]`);
const fDef = gen.const("fDef", (0, codegen_1._) `${fmts}[${schemaCode}]`);
const fType = gen.let("fType");
const format = gen.let("format");
// TODO simplify
gen.if(codegen_1._ `typeof ${fDef} == "object" && !(${fDef} instanceof RegExp)`, () => gen.assign(fType, codegen_1._ `${fDef}.type || "string"`).assign(format, codegen_1._ `${fDef}.validate`), () => gen.assign(fType, codegen_1._ `"string"`).assign(format, fDef));
cxt.fail$data(codegen_1.or(unknownFmt(), invalidFmt()));
gen.if((0, codegen_1._) `typeof ${fDef} == "object" && !(${fDef} instanceof RegExp)`, () => gen.assign(fType, (0, codegen_1._) `${fDef}.type || "string"`).assign(format, (0, codegen_1._) `${fDef}.validate`), () => gen.assign(fType, (0, codegen_1._) `"string"`).assign(format, fDef));
cxt.fail$data((0, codegen_1.or)(unknownFmt(), invalidFmt()));
function unknownFmt() {
if (opts.strictSchema === false)
return codegen_1.nil;
return codegen_1._ `${schemaCode} && !${format}`;
return (0, codegen_1._) `${schemaCode} && !${format}`;
}
function invalidFmt() {
const callFormat = schemaEnv.$async
? codegen_1._ `(${fDef}.async ? await ${format}(${data}) : ${format}(${data}))`
: codegen_1._ `${format}(${data})`;
const validData = codegen_1._ `(typeof ${format} == "function" ? ${callFormat} : ${format}.test(${data}))`;
return codegen_1._ `${format} && ${format} !== true && ${fType} === ${ruleType} && !${validData}`;
? (0, codegen_1._) `(${fDef}.async ? await ${format}(${data}) : ${format}(${data}))`
: (0, codegen_1._) `${format}(${data})`;
const validData = (0, codegen_1._) `(typeof ${format} == "function" ? ${callFormat} : ${format}.test(${data}))`;
return (0, codegen_1._) `${format} && ${format} !== true && ${fType} === ${ruleType} && !${validData}`;
}

@@ -72,9 +72,9 @@ }

const code = fmtDef instanceof RegExp
? codegen_1.regexpCode(fmtDef)
? (0, codegen_1.regexpCode)(fmtDef)
: opts.code.formats
? codegen_1._ `${opts.code.formats}${codegen_1.getProperty(schema)}`
? (0, codegen_1._) `${opts.code.formats}${(0, codegen_1.getProperty)(schema)}`
: undefined;
const fmt = gen.scopeValue("formats", { key: schema, ref: fmtDef, code });
if (typeof fmtDef == "object" && !(fmtDef instanceof RegExp)) {
return [fmtDef.type || "string", fmtDef.validate, codegen_1._ `${fmt}.validate`];
return [fmtDef.type || "string", fmtDef.validate, (0, codegen_1._) `${fmt}.validate`];
}

@@ -87,5 +87,5 @@ return ["string", fmtDef, fmt];

throw new Error("async format in sync schema");
return codegen_1._ `await ${fmtRef}(${data})`;
return (0, codegen_1._) `await ${fmtRef}(${data})`;
}
return typeof format == "function" ? codegen_1._ `${fmtRef}(${data})` : codegen_1._ `${fmtRef}.test(${data})`;
return typeof format == "function" ? (0, codegen_1._) `${fmtRef}(${data})` : (0, codegen_1._) `${fmtRef}.test(${data})`;
}

@@ -92,0 +92,0 @@ }

@@ -15,3 +15,3 @@ "use strict";

: `value of tag "${schema}" must be in mapping`
: error_1.typeErrorMessage(cxt, "object");
: (0, error_1.typeErrorMessage)(cxt, "object");
},

@@ -21,4 +21,4 @@ params: (cxt) => {

return params.discrError
? codegen_1._ `{error: ${params.discrError}, tag: ${schema}, tagValue: ${params.tag}}`
: error_1.typeErrorParams(cxt, "object");
? (0, codegen_1._) `{error: ${params.discrError}, tag: ${schema}, tagValue: ${params.tag}}`
: (0, error_1.typeErrorParams)(cxt, "object");
},

@@ -32,8 +32,8 @@ };

code(cxt) {
metadata_1.checkMetadata(cxt);
(0, metadata_1.checkMetadata)(cxt);
const { gen, data, schema, parentSchema } = cxt;
const [valid, cond] = nullable_1.checkNullableObject(cxt, data);
const [valid, cond] = (0, nullable_1.checkNullableObject)(cxt, data);
gen.if(cond);
validateDiscriminator();
gen.elseIf(codegen_1.not(valid));
gen.elseIf((0, codegen_1.not)(valid));
cxt.error();

@@ -43,6 +43,6 @@ gen.endIf();

function validateDiscriminator() {
const tag = gen.const("tag", codegen_1._ `${data}${codegen_1.getProperty(schema)}`);
gen.if(codegen_1._ `${tag} === undefined`);
const tag = gen.const("tag", (0, codegen_1._) `${data}${(0, codegen_1.getProperty)(schema)}`);
gen.if((0, codegen_1._) `${tag} === undefined`);
cxt.error(false, { discrError: types_1.DiscrError.Tag, tag });
gen.elseIf(codegen_1._ `typeof ${tag} == "string"`);
gen.elseIf((0, codegen_1._) `typeof ${tag} == "string"`);
validateMapping(tag);

@@ -56,3 +56,3 @@ gen.else();

for (const tagValue in parentSchema.mapping) {
gen.elseIf(codegen_1._ `${tag} === ${tagValue}`);
gen.elseIf((0, codegen_1._) `${tag} === ${tagValue}`);
gen.assign(valid, applyTagSchema(tagValue));

@@ -59,0 +59,0 @@ }

@@ -12,10 +12,10 @@ "use strict";

schemaType: "object",
error: error_1.typeError("array"),
error: (0, error_1.typeError)("array"),
code(cxt) {
metadata_1.checkMetadata(cxt);
(0, metadata_1.checkMetadata)(cxt);
const { gen, data, schema, it } = cxt;
if (util_1.alwaysValidSchema(it, schema))
if ((0, util_1.alwaysValidSchema)(it, schema))
return;
const [valid] = nullable_1.checkNullable(cxt);
gen.if(codegen_1.not(valid), () => gen.if(codegen_1._ `Array.isArray(${data})`, () => gen.assign(valid, code_1.validateArray(cxt)), () => cxt.error()));
const [valid] = (0, nullable_1.checkNullable)(cxt);
gen.if((0, codegen_1.not)(valid), () => gen.if((0, codegen_1._) `Array.isArray(${data})`, () => gen.assign(valid, (0, code_1.validateArray)(cxt)), () => cxt.error()));
cxt.ok(valid);

@@ -22,0 +22,0 @@ },

@@ -8,3 +8,3 @@ "use strict";

message: "must be equal to one of the allowed values",
params: ({ schemaCode }) => codegen_1._ `{allowedValues: ${schemaCode}}`,
params: ({ schemaCode }) => (0, codegen_1._) `{allowedValues: ${schemaCode}}`,
};

@@ -16,3 +16,3 @@ const def = {

code(cxt) {
metadata_1.checkMetadata(cxt);
(0, metadata_1.checkMetadata)(cxt);
const { gen, data, schema, schemaValue, parentSchema, it } = cxt;

@@ -24,6 +24,6 @@ if (schema.length === 0)

let valid;
const isString = codegen_1._ `typeof ${data} == "string"`;
const isString = (0, codegen_1._) `typeof ${data} == "string"`;
if (schema.length >= it.opts.loopEnum) {
let cond;
[valid, cond] = nullable_1.checkNullable(cxt, isString);
[valid, cond] = (0, nullable_1.checkNullable)(cxt, isString);
gen.if(cond, loopEnum);

@@ -35,9 +35,9 @@ }

throw new Error("ajv implementation error");
valid = codegen_1.and(isString, codegen_1.or(...schema.map((value) => codegen_1._ `${data} === ${value}`)));
valid = (0, codegen_1.and)(isString, (0, codegen_1.or)(...schema.map((value) => (0, codegen_1._) `${data} === ${value}`)));
if (parentSchema.nullable)
valid = codegen_1.or(codegen_1._ `${data} === null`, valid);
valid = (0, codegen_1.or)((0, codegen_1._) `${data} === null`, valid);
}
cxt.pass(valid);
function loopEnum() {
gen.forOf("v", schemaValue, (v) => gen.if(codegen_1._ `${valid} = ${data} === ${v}`, () => gen.break()));
gen.forOf("v", schemaValue, (v) => gen.if((0, codegen_1._) `${valid} = ${data} === ${v}`, () => gen.break()));
}

@@ -44,0 +44,0 @@ },

@@ -17,5 +17,5 @@ "use strict";

function typeErrorParams({ parentSchema }, t) {
return codegen_1._ `{type: ${t}, nullable: ${!!(parentSchema === null || parentSchema === void 0 ? void 0 : parentSchema.nullable)}}`;
return (0, codegen_1._) `{type: ${t}, nullable: ${!!(parentSchema === null || parentSchema === void 0 ? void 0 : parentSchema.nullable)}}`;
}
exports.typeErrorParams = typeErrorParams;
//# sourceMappingURL=error.js.map

@@ -11,3 +11,3 @@ "use strict";

const { gen, schema, it } = cxt;
if (util_1.alwaysValidSchema(it, schema))
if ((0, util_1.alwaysValidSchema)(it, schema))
return;

@@ -14,0 +14,0 @@ const valid = gen.name("valid");

@@ -8,4 +8,4 @@ "use strict";

if (parentSchema.nullable) {
gen.let(valid, codegen_1._ `${data} === null`);
cond = codegen_1.not(valid);
gen.let(valid, (0, codegen_1._) `${data} === null`);
cond = (0, codegen_1.not)(valid);
}

@@ -20,5 +20,5 @@ else {

const [valid, cond_] = checkNullable(cxt, cond);
return [valid, codegen_1._ `${cond_} && typeof ${cxt.data} == "object" && !Array.isArray(${cxt.data})`];
return [valid, (0, codegen_1._) `${cond_} && typeof ${cxt.data} == "object" && !Array.isArray(${cxt.data})`];
}
exports.checkNullableObject = checkNullableObject;
//# sourceMappingURL=nullable.js.map

@@ -11,3 +11,3 @@ "use strict";

return;
properties_1.validateProperties(cxt);
(0, properties_1.validateProperties)(cxt);
},

@@ -14,0 +14,0 @@ };

@@ -22,3 +22,3 @@ "use strict";

: `must have property '${params.missingProperty}'`
: error_1.typeErrorMessage(cxt, "object");
: (0, error_1.typeErrorMessage)(cxt, "object");
},

@@ -29,5 +29,5 @@ params: (cxt) => {

? params.propError === PropError.Additional
? codegen_1._ `{error: ${params.propError}, additionalProperty: ${params.additionalProperty}}`
: codegen_1._ `{error: ${params.propError}, missingProperty: ${params.missingProperty}}`
: error_1.typeErrorParams(cxt, "object");
? (0, codegen_1._) `{error: ${params.propError}, additionalProperty: ${params.additionalProperty}}`
: (0, codegen_1._) `{error: ${params.propError}, missingProperty: ${params.missingProperty}}`
: (0, error_1.typeErrorParams)(cxt, "object");
},

@@ -46,3 +46,3 @@ };

function validateProperties(cxt) {
metadata_1.checkMetadata(cxt);
(0, metadata_1.checkMetadata)(cxt);
const { gen, data, parentSchema, it } = cxt;

@@ -61,3 +61,3 @@ const { additionalProperties, nullable } = parentSchema;

const [valid, cond] = it.jtdDiscriminator === undefined
? nullable_1.checkNullableObject(cxt, data)
? (0, nullable_1.checkNullableObject)(cxt, data)
: [gen.let("valid", false), true];

@@ -84,7 +84,7 @@ gen.if(cond, () => gen.assign(valid, true).block(() => {

const schema = parentSchema[keyword];
const allPs = schema ? code_1.allSchemaProperties(schema) : [];
const allPs = schema ? (0, code_1.allSchemaProperties)(schema) : [];
if (it.jtdDiscriminator && allPs.some((p) => p === it.jtdDiscriminator)) {
throw new Error(`JTD: discriminator tag used in ${keyword}`);
}
const ps = allPs.filter((p) => !util_1.alwaysValidSchema(it, schema[p]));
const ps = allPs.filter((p) => !(0, util_1.alwaysValidSchema)(it, schema[p]));
return [allPs, ps];

@@ -95,3 +95,3 @@ }

for (const prop of props) {
gen.if(code_1.propertyInData(gen, data, prop, it.opts.ownProperties), () => applyPropertySchema(prop, keyword, _valid), () => missingProperty(prop));
gen.if((0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties), () => applyPropertySchema(prop, keyword, _valid), () => missingProperty(prop));
cxt.ok(_valid);

@@ -121,6 +121,6 @@ }

const addOptProp = isAdditional(key, allOptProps, "optionalProperties");
const extra = addProp === true ? addOptProp : addOptProp === true ? addProp : codegen_1.and(addProp, addOptProp);
const extra = addProp === true ? addOptProp : addOptProp === true ? addProp : (0, codegen_1.and)(addProp, addOptProp);
gen.if(extra, () => {
if (it.opts.removeAdditional) {
gen.code(codegen_1._ `delete ${data}[${key}]`);
gen.code((0, codegen_1._) `delete ${data}[${key}]`);
}

@@ -139,7 +139,7 @@ else {

// TODO maybe an option instead of hard-coded 8?
const propsSchema = util_1.schemaRefOrVal(it, parentSchema[keyword], keyword);
additional = codegen_1.not(code_1.isOwnProperty(gen, propsSchema, key));
const propsSchema = (0, util_1.schemaRefOrVal)(it, parentSchema[keyword], keyword);
additional = (0, codegen_1.not)((0, code_1.isOwnProperty)(gen, propsSchema, key));
}
else if (props.length) {
additional = codegen_1.and(...props.map((p) => codegen_1._ `${key} !== ${p}`));
additional = (0, codegen_1.and)(...props.map((p) => (0, codegen_1._) `${key} !== ${p}`));
}

@@ -146,0 +146,0 @@ else {

@@ -14,3 +14,3 @@ "use strict";

code(cxt) {
metadata_1.checkMetadata(cxt);
(0, metadata_1.checkMetadata)(cxt);
const { gen, data, schema: ref, parentSchema, it } = cxt;

@@ -20,4 +20,4 @@ const { schemaEnv: { root }, } = it;

if (parentSchema.nullable) {
gen.var(valid, codegen_1._ `${data} === null`);
gen.if(codegen_1.not(valid), validateJtdRef);
gen.var(valid, (0, codegen_1._) `${data} === null`);
gen.if((0, codegen_1.not)(valid), validateJtdRef);
}

@@ -41,9 +41,9 @@ else {

const sch = compile_1.compileSchema.call(it.self, new compile_1.SchemaEnv({ schema, root, schemaPath: `/definitions/${ref}` }));
const v = ref_1.getValidate(cxt, sch);
const v = (0, ref_1.getValidate)(cxt, sch);
const errsCount = gen.const("_errs", names_1.default.errors);
ref_1.callRef(cxt, v, sch, sch.$async);
gen.assign(valid, codegen_1._ `${errsCount} === ${names_1.default.errors}`);
(0, ref_1.callRef)(cxt, v, sch, sch.$async);
gen.assign(valid, (0, codegen_1._) `${errsCount} === ${names_1.default.errors}`);
}
function inlineRefSchema(schema) {
const schName = gen.scopeValue("schema", it.opts.code.source === true ? { ref: schema, code: codegen_1.stringify(schema) } : { ref: schema });
const schName = gen.scopeValue("schema", it.opts.code.source === true ? { ref: schema, code: (0, codegen_1.stringify)(schema) } : { ref: schema });
cxt.subschema({

@@ -50,0 +50,0 @@ schema,

@@ -18,4 +18,4 @@ "use strict";

const error = {
message: (cxt) => error_1.typeErrorMessage(cxt, cxt.schema),
params: (cxt) => error_1.typeErrorParams(cxt, cxt.schema),
message: (cxt) => (0, error_1.typeErrorMessage)(cxt, cxt.schema),
params: (cxt) => (0, error_1.typeErrorParams)(cxt, cxt.schema),
};

@@ -26,7 +26,7 @@ function timestampCode(cxt) {

if (timestamp === "date")
return codegen_1._ `${data} instanceof Date `;
const vts = util_1.useFunc(gen, timestamp_1.default);
const allowDateArg = allowDate ? codegen_1._ `, true` : codegen_1.nil;
const validString = codegen_1._ `typeof ${data} == "string" && ${vts}(${data}${allowDateArg})`;
return timestamp === "string" ? validString : codegen_1.or(codegen_1._ `${data} instanceof Date`, validString);
return (0, codegen_1._) `${data} instanceof Date `;
const vts = (0, util_1.useFunc)(gen, timestamp_1.default);
const allowDateArg = allowDate ? (0, codegen_1._) `, true` : codegen_1.nil;
const validString = (0, codegen_1._) `typeof ${data} == "string" && ${vts}(${data}${allowDateArg})`;
return timestamp === "string" ? validString : (0, codegen_1.or)((0, codegen_1._) `${data} instanceof Date`, validString);
}

@@ -38,3 +38,3 @@ const def = {

code(cxt) {
metadata_1.checkMetadata(cxt);
(0, metadata_1.checkMetadata)(cxt);
const { data, schema, parentSchema, it } = cxt;

@@ -45,3 +45,3 @@ let cond;

case "string":
cond = codegen_1._ `typeof ${data} == ${schema}`;
cond = (0, codegen_1._) `typeof ${data} == ${schema}`;
break;

@@ -54,18 +54,18 @@ case "timestamp": {

case "float64":
cond = codegen_1._ `typeof ${data} == "number"`;
cond = (0, codegen_1._) `typeof ${data} == "number"`;
break;
default: {
const sch = schema;
cond = codegen_1._ `typeof ${data} == "number" && isFinite(${data}) && !(${data} % 1)`;
cond = (0, codegen_1._) `typeof ${data} == "number" && isFinite(${data}) && !(${data} % 1)`;
if (!it.opts.int32range && (sch === "int32" || sch === "uint32")) {
if (sch === "uint32")
cond = codegen_1._ `${cond} && ${data} >= 0`;
cond = (0, codegen_1._) `${cond} && ${data} >= 0`;
}
else {
const [min, max] = exports.intRange[sch];
cond = codegen_1._ `${cond} && ${data} >= ${min} && ${data} <= ${max}`;
cond = (0, codegen_1._) `${cond} && ${data} >= ${min} && ${data} <= ${max}`;
}
}
}
cxt.pass(parentSchema.nullable ? codegen_1.or(codegen_1._ `${data} === null`, cond) : cond);
cxt.pass(parentSchema.nullable ? (0, codegen_1.or)((0, codegen_1._) `${data} === null`, cond) : cond);
},

@@ -72,0 +72,0 @@ };

@@ -11,12 +11,12 @@ "use strict";

schemaType: "object",
error: error_1.typeError("object"),
error: (0, error_1.typeError)("object"),
code(cxt) {
metadata_1.checkMetadata(cxt);
(0, metadata_1.checkMetadata)(cxt);
const { gen, data, schema, it } = cxt;
if (util_1.alwaysValidSchema(it, schema))
if ((0, util_1.alwaysValidSchema)(it, schema))
return;
const [valid, cond] = nullable_1.checkNullableObject(cxt, data);
const [valid, cond] = (0, nullable_1.checkNullableObject)(cxt, data);
gen.if(cond);
gen.assign(valid, validateMap());
gen.elseIf(codegen_1.not(valid));
gen.elseIf((0, codegen_1.not)(valid));
cxt.error();

@@ -42,3 +42,3 @@ gen.endIf();

}, _valid);
gen.if(codegen_1.not(_valid), notValid);
gen.if((0, codegen_1.not)(_valid), notValid);
});

@@ -45,0 +45,0 @@ }

@@ -6,4 +6,4 @@ "use strict";

const error = {
message: ({ params: { len } }) => codegen_1.str `must NOT have more than ${len} items`,
params: ({ params: { len } }) => codegen_1._ `{limit: ${len}}`,
message: ({ params: { len } }) => (0, codegen_1.str) `must NOT have more than ${len} items`,
params: ({ params: { len } }) => (0, codegen_1._) `{limit: ${len}}`,
};

@@ -20,10 +20,10 @@ const def = {

return;
const len = gen.const("len", codegen_1._ `${data}.length`);
const len = gen.const("len", (0, codegen_1._) `${data}.length`);
if (schema === false) {
cxt.setParams({ len: items });
cxt.fail(codegen_1._ `${len} > ${items}`);
cxt.fail((0, codegen_1._) `${len} > ${items}`);
}
else if (typeof schema == "object" && !util_1.alwaysValidSchema(it, schema)) {
const valid = gen.var("valid", codegen_1._ `${len} <= ${items}`);
gen.if(codegen_1.not(valid), () => validateItems(valid, items));
else if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) {
const valid = gen.var("valid", (0, codegen_1._) `${len} <= ${items}`);
gen.if((0, codegen_1.not)(valid), () => validateItems(valid, items));
cxt.ok(valid);

@@ -36,3 +36,3 @@ }

if (!it.allErrors)
gen.if(codegen_1.not(valid), () => gen.break());
gen.if((0, codegen_1.not)(valid), () => gen.break());
});

@@ -39,0 +39,0 @@ }

@@ -8,3 +8,3 @@ "use strict";

message: "must NOT have unevaluated properties",
params: ({ params }) => codegen_1._ `{unevaluatedProperty: ${params.unevaluatedProperty}}`,
params: ({ params }) => (0, codegen_1._) `{unevaluatedProperty: ${params.unevaluatedProperty}}`,
};

@@ -24,3 +24,3 @@ const def = {

if (props instanceof codegen_1.Name) {
gen.if(codegen_1._ `${props} !== true`, () => gen.forIn("key", data, (key) => gen.if(unevaluatedDynamic(props, key), () => unevaluatedPropCode(key))));
gen.if((0, codegen_1._) `${props} !== true`, () => gen.forIn("key", data, (key) => gen.if(unevaluatedDynamic(props, key), () => unevaluatedPropCode(key))));
}

@@ -33,3 +33,3 @@ else if (props !== true) {

it.props = true;
cxt.ok(codegen_1._ `${errsCount} === ${names_1.default.errors}`);
cxt.ok((0, codegen_1._) `${errsCount} === ${names_1.default.errors}`);
function unevaluatedPropCode(key) {

@@ -43,3 +43,3 @@ if (schema === false) {

}
if (!util_1.alwaysValidSchema(it, schema)) {
if (!(0, util_1.alwaysValidSchema)(it, schema)) {
const valid = gen.name("valid");

@@ -52,7 +52,7 @@ cxt.subschema({

if (!allErrors)
gen.if(codegen_1.not(valid), () => gen.break());
gen.if((0, codegen_1.not)(valid), () => gen.break());
}
}
function unevaluatedDynamic(evaluatedProps, key) {
return codegen_1._ `!${evaluatedProps} || !${evaluatedProps}[${key}]`;
return (0, codegen_1._) `!${evaluatedProps} || !${evaluatedProps}[${key}]`;
}

@@ -63,5 +63,5 @@ function unevaluatedStatic(evaluatedProps, key) {

if (evaluatedProps[p] === true)
ps.push(codegen_1._ `${key} !== ${p}`);
ps.push((0, codegen_1._) `${key} !== ${p}`);
}
return codegen_1.and(...ps);
return (0, codegen_1.and)(...ps);
}

@@ -68,0 +68,0 @@ },

@@ -8,3 +8,3 @@ "use strict";

message: "must be equal to constant",
params: ({ schemaCode }) => codegen_1._ `{allowedValue: ${schemaCode}}`,
params: ({ schemaCode }) => (0, codegen_1._) `{allowedValue: ${schemaCode}}`,
};

@@ -18,6 +18,6 @@ const def = {

if ($data || (schema && typeof schema == "object")) {
cxt.fail$data(codegen_1._ `!${util_1.useFunc(gen, equal_1.default)}(${data}, ${schemaCode})`);
cxt.fail$data((0, codegen_1._) `!${(0, util_1.useFunc)(gen, equal_1.default)}(${data}, ${schemaCode})`);
}
else {
cxt.fail(codegen_1._ `${schema} !== ${data}`);
cxt.fail((0, codegen_1._) `${schema} !== ${data}`);
}

@@ -24,0 +24,0 @@ },

@@ -9,5 +9,5 @@ "use strict";

error: dependencies_1.error,
code: (cxt) => dependencies_1.validatePropertyDeps(cxt),
code: (cxt) => (0, dependencies_1.validatePropertyDeps)(cxt),
};
exports.default = def;
//# sourceMappingURL=dependentRequired.js.map

@@ -8,3 +8,3 @@ "use strict";

message: "must be equal to one of the allowed values",
params: ({ schemaCode }) => codegen_1._ `{allowedValues: ${schemaCode}}`,
params: ({ schemaCode }) => (0, codegen_1._) `{allowedValues: ${schemaCode}}`,
};

@@ -21,3 +21,3 @@ const def = {

const useLoop = schema.length >= it.opts.loopEnum;
const eql = util_1.useFunc(gen, equal_1.default);
const eql = (0, util_1.useFunc)(gen, equal_1.default);
let valid;

@@ -33,3 +33,3 @@ if (useLoop || $data) {

const vSchema = gen.const("vSchema", schemaCode);
valid = codegen_1.or(...schema.map((_x, i) => equalCode(vSchema, i)));
valid = (0, codegen_1.or)(...schema.map((_x, i) => equalCode(vSchema, i)));
}

@@ -39,3 +39,3 @@ cxt.pass(valid);

gen.assign(valid, false);
gen.forOf("v", schemaCode, (v) => gen.if(codegen_1._ `${eql}(${data}, ${v})`, () => gen.assign(valid, true).break()));
gen.forOf("v", schemaCode, (v) => gen.if((0, codegen_1._) `${eql}(${data}, ${v})`, () => gen.assign(valid, true).break()));
}

@@ -45,4 +45,4 @@ function equalCode(vSchema, i) {

return typeof sch === "object" && sch !== null
? codegen_1._ `${eql}(${data}, ${vSchema}[${i}])`
: codegen_1._ `${data} === ${sch}`;
? (0, codegen_1._) `${eql}(${data}, ${vSchema}[${i}])`
: (0, codegen_1._) `${data} === ${sch}`;
}

@@ -49,0 +49,0 @@ },

@@ -10,3 +10,3 @@ "use strict";

if (parentSchema.contains === undefined) {
util_1.checkStrictMode(it, `"${keyword}" without "contains" is ignored`);
(0, util_1.checkStrictMode)(it, `"${keyword}" without "contains" is ignored`);
}

@@ -13,0 +13,0 @@ },

@@ -7,5 +7,5 @@ "use strict";

const comp = keyword === "maxItems" ? "more" : "fewer";
return codegen_1.str `must NOT have ${comp} than ${schemaCode} items`;
return (0, codegen_1.str) `must NOT have ${comp} than ${schemaCode} items`;
},
params: ({ schemaCode }) => codegen_1._ `{limit: ${schemaCode}}`,
params: ({ schemaCode }) => (0, codegen_1._) `{limit: ${schemaCode}}`,
};

@@ -21,3 +21,3 @@ const def = {

const op = keyword === "maxItems" ? codegen_1.operators.GT : codegen_1.operators.LT;
cxt.fail$data(codegen_1._ `${data}.length ${op} ${schemaCode}`);
cxt.fail$data((0, codegen_1._) `${data}.length ${op} ${schemaCode}`);
},

@@ -24,0 +24,0 @@ };

@@ -9,5 +9,5 @@ "use strict";

const comp = keyword === "maxLength" ? "more" : "fewer";
return codegen_1.str `must NOT have ${comp} than ${schemaCode} characters`;
return (0, codegen_1.str) `must NOT have ${comp} than ${schemaCode} characters`;
},
params: ({ schemaCode }) => codegen_1._ `{limit: ${schemaCode}}`,
params: ({ schemaCode }) => (0, codegen_1._) `{limit: ${schemaCode}}`,
};

@@ -23,4 +23,4 @@ const def = {

const op = keyword === "maxLength" ? codegen_1.operators.GT : codegen_1.operators.LT;
const len = it.opts.unicode === false ? codegen_1._ `${data}.length` : codegen_1._ `${util_1.useFunc(cxt.gen, ucs2length_1.default)}(${data})`;
cxt.fail$data(codegen_1._ `${len} ${op} ${schemaCode}`);
const len = it.opts.unicode === false ? (0, codegen_1._) `${data}.length` : (0, codegen_1._) `${(0, util_1.useFunc)(cxt.gen, ucs2length_1.default)}(${data})`;
cxt.fail$data((0, codegen_1._) `${len} ${op} ${schemaCode}`);
},

@@ -27,0 +27,0 @@ };

@@ -12,4 +12,4 @@ "use strict";

const error = {
message: ({ keyword, schemaCode }) => codegen_1.str `must be ${KWDs[keyword].okStr} ${schemaCode}`,
params: ({ keyword, schemaCode }) => codegen_1._ `{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}`,
message: ({ keyword, schemaCode }) => (0, codegen_1.str) `must be ${KWDs[keyword].okStr} ${schemaCode}`,
params: ({ keyword, schemaCode }) => (0, codegen_1._) `{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}`,
};

@@ -24,3 +24,3 @@ const def = {

const { keyword, data, schemaCode } = cxt;
cxt.fail$data(codegen_1._ `${data} ${KWDs[keyword].fail} ${schemaCode} || isNaN(${data})`);
cxt.fail$data((0, codegen_1._) `${data} ${KWDs[keyword].fail} ${schemaCode} || isNaN(${data})`);
},

@@ -27,0 +27,0 @@ };

@@ -7,5 +7,5 @@ "use strict";

const comp = keyword === "maxProperties" ? "more" : "fewer";
return codegen_1.str `must NOT have ${comp} than ${schemaCode} items`;
return (0, codegen_1.str) `must NOT have ${comp} than ${schemaCode} items`;
},
params: ({ schemaCode }) => codegen_1._ `{limit: ${schemaCode}}`,
params: ({ schemaCode }) => (0, codegen_1._) `{limit: ${schemaCode}}`,
};

@@ -21,3 +21,3 @@ const def = {

const op = keyword === "maxProperties" ? codegen_1.operators.GT : codegen_1.operators.LT;
cxt.fail$data(codegen_1._ `Object.keys(${data}).length ${op} ${schemaCode}`);
cxt.fail$data((0, codegen_1._) `Object.keys(${data}).length ${op} ${schemaCode}`);
},

@@ -24,0 +24,0 @@ };

@@ -5,4 +5,4 @@ "use strict";

const error = {
message: ({ schemaCode }) => codegen_1.str `must be multiple of ${schemaCode}`,
params: ({ schemaCode }) => codegen_1._ `{multipleOf: ${schemaCode}}`,
message: ({ schemaCode }) => (0, codegen_1.str) `must be multiple of ${schemaCode}`,
params: ({ schemaCode }) => (0, codegen_1._) `{multipleOf: ${schemaCode}}`,
};

@@ -21,5 +21,5 @@ const def = {

const invalid = prec
? codegen_1._ `Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}`
: codegen_1._ `${res} !== parseInt(${res})`;
cxt.fail$data(codegen_1._ `(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${invalid}))`);
? (0, codegen_1._) `Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}`
: (0, codegen_1._) `${res} !== parseInt(${res})`;
cxt.fail$data((0, codegen_1._) `(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${invalid}))`);
},

@@ -26,0 +26,0 @@ };

@@ -6,4 +6,4 @@ "use strict";

const error = {
message: ({ schemaCode }) => codegen_1.str `must match pattern "${schemaCode}"`,
params: ({ schemaCode }) => codegen_1._ `{pattern: ${schemaCode}}`,
message: ({ schemaCode }) => (0, codegen_1.str) `must match pattern "${schemaCode}"`,
params: ({ schemaCode }) => (0, codegen_1._) `{pattern: ${schemaCode}}`,
};

@@ -20,4 +20,4 @@ const def = {

const u = it.opts.unicodeRegExp ? "u" : "";
const regExp = $data ? codegen_1._ `(new RegExp(${schemaCode}, ${u}))` : code_1.usePattern(cxt, schema);
cxt.fail$data(codegen_1._ `!${regExp}.test(${data})`);
const regExp = $data ? (0, codegen_1._) `(new RegExp(${schemaCode}, ${u}))` : (0, code_1.usePattern)(cxt, schema);
cxt.fail$data((0, codegen_1._) `!${regExp}.test(${data})`);
},

@@ -24,0 +24,0 @@ };

@@ -7,4 +7,4 @@ "use strict";

const error = {
message: ({ params: { missingProperty } }) => codegen_1.str `must have required property '${missingProperty}'`,
params: ({ params: { missingProperty } }) => codegen_1._ `{missingProperty: ${missingProperty}}`,
message: ({ params: { missingProperty } }) => (0, codegen_1.str) `must have required property '${missingProperty}'`,
params: ({ params: { missingProperty } }) => (0, codegen_1._) `{missingProperty: ${missingProperty}}`,
};

@@ -34,3 +34,3 @@ const def = {

const msg = `required property "${requiredKey}" is not defined at "${schemaPath}" (strictRequired)`;
util_1.checkStrictMode(it, msg, it.opts.strictRequired);
(0, util_1.checkStrictMode)(it, msg, it.opts.strictRequired);
}

@@ -45,3 +45,3 @@ }

for (const prop of schema) {
code_1.checkReportMissingProp(cxt, prop);
(0, code_1.checkReportMissingProp)(cxt, prop);
}

@@ -58,4 +58,4 @@ }

else {
gen.if(code_1.checkMissingProp(cxt, schema, missing));
code_1.reportMissingProp(cxt, missing);
gen.if((0, code_1.checkMissingProp)(cxt, schema, missing));
(0, code_1.reportMissingProp)(cxt, missing);
gen.else();

@@ -67,3 +67,3 @@ }

cxt.setParams({ missingProperty: prop });
gen.if(code_1.noPropertyInData(gen, data, prop, opts.ownProperties), () => cxt.error());
gen.if((0, code_1.noPropertyInData)(gen, data, prop, opts.ownProperties), () => cxt.error());
});

@@ -74,4 +74,4 @@ }

gen.forOf(missing, schemaCode, () => {
gen.assign(valid, code_1.propertyInData(gen, data, missing, opts.ownProperties));
gen.if(codegen_1.not(valid), () => {
gen.assign(valid, (0, code_1.propertyInData)(gen, data, missing, opts.ownProperties));
gen.if((0, codegen_1.not)(valid), () => {
cxt.error();

@@ -78,0 +78,0 @@ gen.break();

@@ -8,4 +8,4 @@ "use strict";

const error = {
message: ({ params: { i, j } }) => codegen_1.str `must NOT have duplicate items (items ## ${j} and ${i} are identical)`,
params: ({ params: { i, j } }) => codegen_1._ `{i: ${i}, j: ${j}}`,
message: ({ params: { i, j } }) => (0, codegen_1.str) `must NOT have duplicate items (items ## ${j} and ${i} are identical)`,
params: ({ params: { i, j } }) => (0, codegen_1._) `{i: ${i}, j: ${j}}`,
};

@@ -23,11 +23,11 @@ const def = {

const valid = gen.let("valid");
const itemTypes = parentSchema.items ? dataType_1.getSchemaTypes(parentSchema.items) : [];
cxt.block$data(valid, validateUniqueItems, codegen_1._ `${schemaCode} === false`);
const itemTypes = parentSchema.items ? (0, dataType_1.getSchemaTypes)(parentSchema.items) : [];
cxt.block$data(valid, validateUniqueItems, (0, codegen_1._) `${schemaCode} === false`);
cxt.ok(valid);
function validateUniqueItems() {
const i = gen.let("i", codegen_1._ `${data}.length`);
const i = gen.let("i", (0, codegen_1._) `${data}.length`);
const j = gen.let("j");
cxt.setParams({ i, j });
gen.assign(valid, true);
gen.if(codegen_1._ `${i} > 1`, () => (canOptimize() ? loopN : loopN2)(i, j));
gen.if((0, codegen_1._) `${i} > 1`, () => (canOptimize() ? loopN : loopN2)(i, j));
}

@@ -39,22 +39,22 @@ function canOptimize() {

const item = gen.name("item");
const wrongType = dataType_1.checkDataTypes(itemTypes, item, it.opts.strictNumbers, dataType_1.DataType.Wrong);
const indices = gen.const("indices", codegen_1._ `{}`);
gen.for(codegen_1._ `;${i}--;`, () => {
gen.let(item, codegen_1._ `${data}[${i}]`);
gen.if(wrongType, codegen_1._ `continue`);
const wrongType = (0, dataType_1.checkDataTypes)(itemTypes, item, it.opts.strictNumbers, dataType_1.DataType.Wrong);
const indices = gen.const("indices", (0, codegen_1._) `{}`);
gen.for((0, codegen_1._) `;${i}--;`, () => {
gen.let(item, (0, codegen_1._) `${data}[${i}]`);
gen.if(wrongType, (0, codegen_1._) `continue`);
if (itemTypes.length > 1)
gen.if(codegen_1._ `typeof ${item} == "string"`, codegen_1._ `${item} += "_"`);
gen.if((0, codegen_1._) `typeof ${item} == "string"`, (0, codegen_1._) `${item} += "_"`);
gen
.if(codegen_1._ `typeof ${indices}[${item}] == "number"`, () => {
gen.assign(j, codegen_1._ `${indices}[${item}]`);
.if((0, codegen_1._) `typeof ${indices}[${item}] == "number"`, () => {
gen.assign(j, (0, codegen_1._) `${indices}[${item}]`);
cxt.error();
gen.assign(valid, false).break();
})
.code(codegen_1._ `${indices}[${item}] = ${i}`);
.code((0, codegen_1._) `${indices}[${item}] = ${i}`);
});
}
function loopN2(i, j) {
const eql = util_1.useFunc(gen, equal_1.default);
const eql = (0, util_1.useFunc)(gen, equal_1.default);
const outer = gen.name("outer");
gen.label(outer).for(codegen_1._ `;${i}--;`, () => gen.for(codegen_1._ `${j} = ${i}; ${j}--;`, () => gen.if(codegen_1._ `${eql}(${data}[${i}], ${data}[${j}])`, () => {
gen.label(outer).for((0, codegen_1._) `;${i}--;`, () => gen.for((0, codegen_1._) `${j} = ${i}; ${j}--;`, () => gen.if((0, codegen_1._) `${eql}(${data}[${i}], ${data}[${j}])`, () => {
cxt.error();

@@ -61,0 +61,0 @@ gen.assign(valid, false).break(outer);

@@ -303,7 +303,8 @@ import type {

for (const part of parsedRef.fragment.slice(1).split("/")) {
if (typeof schema == "boolean") return
schema = schema[unescapeFragment(part)]
if (schema === undefined) return
if (typeof schema === "boolean") return
const partSchema = schema[unescapeFragment(part)]
if (partSchema === undefined) return
schema = partSchema
// TODO PREVENT_SCOPE_CHANGE could be defined in keyword def?
const schId = typeof schema == "object" && schema[this.opts.schemaId]
const schId = typeof schema === "object" && schema[this.opts.schemaId]
if (!PREVENT_SCOPE_CHANGE.has(part) && schId) {

@@ -310,0 +311,0 @@ baseId = resolveUrl(baseId, schId)

@@ -92,6 +92,6 @@ import type {AnySchema, AnySchemaObject} from "../types"

export function getSchemaRefs(this: Ajv, schema: AnySchema): LocalRefs {
export function getSchemaRefs(this: Ajv, schema: AnySchema, baseId: string): LocalRefs {
if (typeof schema == "boolean") return {}
const {schemaId} = this.opts
const schId = normalizeId(schema[schemaId])
const schId = normalizeId(schema[schemaId] || baseId)
const baseIds: {[JsonPtr in string]?: string} = {"": schId}

@@ -98,0 +98,0 @@ const pathPrefix = getFullPath(schId, false)

@@ -697,4 +697,4 @@ export {

const localRefs = getSchemaRefs.call(this, schema)
baseId = normalizeId(id || baseId)
const localRefs = getSchemaRefs.call(this, schema, baseId)
sch = new SchemaEnv({schema, schemaId, meta, baseId, localRefs})

@@ -701,0 +701,0 @@ this._cache.set(sch.schema, sch)

@@ -12,3 +12,3 @@ const rxParseJson = /position\s(\d+)$/

} catch (e) {
matches = rxParseJson.exec(e.message)
matches = rxParseJson.exec((e as Error).message)
if (!matches) {

@@ -132,3 +132,8 @@ parseJson.message = "unexpected end"

code <<= 4
c = s[pos].toLowerCase()
c = s[pos]
if (c === undefined) {
errorMessage("unexpected end")
return undefined
}
c = c.toLowerCase()
if (c >= "a" && c <= "f") {

@@ -138,5 +143,2 @@ code += c.charCodeAt(0) - CODE_A + 10

code += c.charCodeAt(0) - CODE_0
} else if (c === undefined) {
errorMessage("unexpected end")
return undefined
} else {

@@ -153,2 +155,3 @@ errorMessage(`unexpected token ${c}`)

}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
} else if (c === undefined) {

@@ -155,0 +158,0 @@ errorMessage("unexpected end")

@@ -7,3 +7,3 @@ import type AjvCore from "../core"

export default function standaloneCode(
function standaloneCode(
ajv: AjvCore,

@@ -90,1 +90,6 @@ refsOrFunc?: {[K in string]?: string} | AnyValidateFunction

}
module.exports = exports = standaloneCode
Object.defineProperty(exports, "__esModule", {value: true})
export default standaloneCode

@@ -6,2 +6,6 @@ /* eslint-disable @typescript-eslint/no-empty-interface */

type UnionToIntersection<U> = (U extends any ? (_: U) => void : never) extends (_: infer I) => void
? I
: never
export type SomeJSONSchema = UncheckedJSONSchemaType<Known, true>

@@ -43,3 +47,3 @@

| ({
type: (T extends number
type: readonly (T extends number
? JSONType<"number" | "integer", IsPartial>

@@ -51,9 +55,12 @@ : T extends string

: never)[]
} & (T extends number
? NumberKeywords
: T extends string
? StringKeywords
: T extends boolean
? unknown
: never))
} & UnionToIntersection<
T extends number
? NumberKeywords
: T extends string
? StringKeywords
: T extends boolean
? // eslint-disable-next-line @typescript-eslint/ban-types
{}
: never
>)
// this covers "normal" types; it's last so typescript looks to it first for errors

@@ -70,5 +77,5 @@ | ((T extends number

? {
type: "boolean"
type: JSONType<"boolean", IsPartial>
}
: T extends [any, ...any[]]
: T extends readonly [any, ...any[]]
? {

@@ -106,3 +113,3 @@ // JSON AnySchema for tuple

: UncheckedPropertiesSchema<T>
patternProperties?: {[Pattern in string]?: UncheckedJSONSchemaType<T[string], false>}
patternProperties?: Record<string, UncheckedJSONSchemaType<T[string], false>>
propertyNames?: Omit<UncheckedJSONSchemaType<string, false>, "type"> & {type?: "string"}

@@ -124,2 +131,3 @@ dependencies?: {[K in keyof T]?: Readonly<(keyof T)[]> | UncheckedPartialSchema<T>}

? {
type: JSONType<"null", IsPartial>
nullable: true

@@ -140,8 +148,4 @@ }

$ref?: string
$defs?: {
[Key in string]?: UncheckedJSONSchemaType<Known, true>
}
definitions?: {
[Key in string]?: UncheckedJSONSchemaType<Known, true>
}
$defs?: Record<string, UncheckedJSONSchemaType<Known, true>>
definitions?: Record<string, UncheckedJSONSchemaType<Known, true>>
}

@@ -154,6 +158,11 @@

type Known = KnownRecord | [Known, ...Known[]] | Known[] | number | string | boolean | null
type Known =
| {[key: string]: Known}
| [Known, ...Known[]]
| Known[]
| number
| string
| boolean
| null
interface KnownRecord extends Record<string, Known> {}
type UncheckedPropertiesSchema<T> = {

@@ -180,3 +189,3 @@ [K in keyof T]-?: (UncheckedJSONSchemaType<T[K], false> & Nullable<T[K]>) | {$ref: string}

nullable: true
const?: never // any non-null value would fail `const: null`, `null` would fail any other value in const
const?: null // any non-null value would fail `const: null`, `null` would fail any other value in const
enum?: Readonly<(T | null)[]> // `null` must be explicitly included in "enum" for `null` to pass

@@ -183,0 +192,0 @@ default?: T | null

@@ -231,10 +231,8 @@ /** numeric strings */

}
? {-readonly [K in keyof S["properties"]]-?: JTDDataDef<S["properties"][K], D>} &
{
-readonly [K in keyof S["optionalProperties"]]+?: JTDDataDef<
S["optionalProperties"][K],
D
>
} &
([S["additionalProperties"]] extends [true] ? Record<string, unknown> : unknown)
? {-readonly [K in keyof S["properties"]]-?: JTDDataDef<S["properties"][K], D>} & {
-readonly [K in keyof S["optionalProperties"]]+?: JTDDataDef<
S["optionalProperties"][K],
D
>
} & ([S["additionalProperties"]] extends [true] ? Record<string, unknown> : unknown)
: S extends {

@@ -245,10 +243,8 @@ properties?: Record<string, unknown>

}
? {-readonly [K in keyof S["properties"]]-?: JTDDataDef<S["properties"][K], D>} &
{
-readonly [K in keyof S["optionalProperties"]]+?: JTDDataDef<
S["optionalProperties"][K],
D
>
} &
([S["additionalProperties"]] extends [true] ? Record<string, unknown> : unknown)
? {-readonly [K in keyof S["properties"]]-?: JTDDataDef<S["properties"][K], D>} & {
-readonly [K in keyof S["optionalProperties"]]+?: JTDDataDef<
S["optionalProperties"][K],
D
>
} & ([S["additionalProperties"]] extends [true] ? Record<string, unknown> : unknown)
: // values

@@ -255,0 +251,0 @@ S extends {values: infer V}

{
"name": "ajv",
"version": "8.6.2",
"version": "8.6.3",
"description": "Another JSON Schema Validator",

@@ -67,3 +67,3 @@ "main": "dist/ajv.js",

"@ajv-validator/config": "^0.3.0",
"@rollup/plugin-commonjs": "^19.0.0",
"@rollup/plugin-commonjs": "^20.0.0",
"@rollup/plugin-json": "^4.1.0",

@@ -73,3 +73,3 @@ "@rollup/plugin-node-resolve": "^13.0.0",

"@types/chai": "^4.2.12",
"@types/mocha": "^8.0.3",
"@types/mocha": "^9.0.0",
"@types/node": "^16.3.2",

@@ -97,4 +97,4 @@ "@types/require-from-string": "^1.2.0",

"lint-staged": "^11.0.0",
"mocha": "^8.0.1",
"node-fetch": "^2.6.1",
"mocha": "^9.0.2",
"node-fetch": "^3.0.0",
"nyc": "^15.0.0",

@@ -101,0 +101,0 @@ "prettier": "^2.3.1",

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

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc