ajv-validator / ajv-validator/ajv-errors

Uncaught SyntaxError: Unexpected token ':'

Đang mở
#157 2 bình luận 6 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
289
Fork
21
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

When running the first example `Single message`[^1] got an error.

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

```bash
$: 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"
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.