ajv-validator / ajv-validator/ajv-cli

Cannot use "constructor" as object property name

オープン
#223 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
316
フォーク
77
PR マージ指標
30日以内にマージされた PR はありません

説明

schema:
```json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"items": {
"type": "object",
"required": [ "answer" ],
"additionalProperties": false,
"properties": {
"answer": {
"type": "object",
"additionalProperties": false,
"properties": {
"constructor": {
"type": "object"
}
}
}
}
}
}
```
json
```json
[
{
"answer": {
"constructor": {
"key": "value"
}
}
},
{
"answer": {}
}
]
```

The above json is deemed invalid. Both array entries should be valid, however ajv deems the last entry to be invalid: `data/1/answer/constructor must be object`

At first it seems like ajv treats the `constructor` property as a required property. However if I rename the property from `constructor` to `constructor2` everything works as expected. (see [Recording](https://user-images.githubusercontent.com/13716661/197217108-5cd375ac-ea0e-4349-b967-83b06a60901a.webm))

**command**: `ajv validate -s schema.json -d data.json --spec=draft2020 --errors=text`
**version**: `ajv-cli@5.0.0`

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。