Skip to content

Issue when compiling standalone validator with ajv-errors and errorMessage:{ properties:{ #88

@lhusson

Description

@lhusson

What version of Ajv are you using?

using ajv 7.1.1 and ajv-errors 2.0.0

Your code


const schema = {
    type: "object",
    properties: {
        foo: {type: "integer", minimum: 2}
    },
    errorMessage: {
        properties: {
            foo: "data.foo should be integer >= 2"
        }
    }
}

const Ajv = require("ajv").default
const ajv = new Ajv({code: {source: true}, allErrors: true})
const standaloneCode = require("ajv/dist/standalone").default
require('ajv-errors')(ajv)

const validate = ajv.compile(schema);
let moduleCode = standaloneCode(ajv, validate)

const fs = require("fs")
const path = require("path")
fs.writeFileSync(path.join(__dirname, 'schema.js'), moduleCode);

error message

node_modules\ajv\dist\compile\codegen\scope.js:134
                    throw new ValueError(name);
                    ^
ValueError: CodeGen: "code" for pattern0 not defined
   

What results did you expect?

this kind of schema is still documented in ajv-errors 2.0.0 documentation, so i expected standalone code to be generated for that schema but seems not

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions