Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Uncaught SyntaxError: Unexpected token ':' #157

Open
@axel7083

Description

When running the first example Single message1 got an error.

$: node --version
v20.17.0
$: node
> const Ajv = require("ajv").default
> const ajv = new Ajv({allErrors: true})
> require("ajv-errors")(ajv /*, {singleError: true} */)
> const schema = {
 type: "object",
 required: ["foo"],
 properties: {
 foo: {type: "integer"},
 },
 additionalProperties: false,
 errorMessage: "should be an object with an integer property foo only",
}
> const validate = ajv.compile(schema)
Error compiling schema, function code: const schema16 = scope.schema[10];return function validate14(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;if(data && typeof data == "object" && !Array.isArray(data)){if(data.foo === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "foo"},message:"must have required property '"+"foo"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(key0 === "foo")){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.foo !== undefined){let data0 = data.foo;if(!(((typeof data0 == "number") && (!(data0 % 1) && !isNaN(data0))) && (isFinite(data0)))){const err2 = {instancePath:instancePath+"/foo",schemaPath:"#/properties/foo/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}}else {const err3 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(errors > 0){for(const err4 of vErrors){if((((({"str":"err4"}.keyword !== "errorMessage") && (!{"str":"err4"}.emUsed)) && (({"str":"err4"}.instancePath === instancePath) || (({"str":"err4"}.instancePath.indexOf(instancePath) === 0) && ({"str":"err4"}.instancePath[instancePath.length] === "/")))) && ({"str":"err4"}.schemaPath.indexOf("#") === 0)) && ({"str":"err4"}.schemaPath["#".length] === "/")){{"str":"emErrs0"}.push({"str":"err4"});{"str":"err4"}.emUsed = true;}}if({"str":"emErrs0"}.length){if(vErrors === null){vErrors = [{"str":"err5"}];}else {vErrors.push({"str":"err5"});}errors++;}const emErrs1 = [];for(const err6 of vErrors){if(!{"str":"err6"}.emUsed){{"str":"emErrs1"}.push({"str":"err6"});}}vErrors = emErrs1;errors = {"str":"emErrs1"}.length;}validate14.errors = vErrors;return errors === 0;}
Uncaught SyntaxError: Unexpected token ':'

Details

My package.json

 "ajv": "^8.17.1",
 "ajv-errors": "^3.0.0"

Footnotes

  1. https://ajv.js.org/packages/ajv-errors.html#single-message

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

        AltStyle によって変換されたページ (->オリジナル) /