ajv-validator / ajv-validator/ajv

Resolve $ref in custom keyword

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

説明

**What version of Ajv you are you using?**

8.11.0

**What problem do you want to solve?**

Use $ref in custom keywords

**What do you think is the correct solution to problem?**

JSON Schema
```
{
"type": "object",
"$ref": "#/$defs/schemas/Account-Ditigal-Documents",
"validators": [
{
"$ref": "#/$defs/validators/tax_residence_country_vdalidator"
}
],
"$defs": {
"validators": {
"tax_residence_country_vdalidator": {
"name": "",
"func": "function tax_residence_country() {a.newAttr = {a: 1} ; return data.homeAddress.legalResidenceCountry == data.taxInfo.taxResidenceCountry }",
"args": []
}
}
}
```

Code

```
ajv.addKeyword({
keyword: "validators",
type: "object",
schemaType: "array",
validate: function (schema, data, parentSchema, dataCxt) {
console.log(schema);
return true;
},
errors: false,
});
```

the parameter`schema` is

```
[
{
"$ref": "#/$defs/validators/tax_residence_country_vdalidator"
}
]
```

expect

```
[
{
"name": "",
"func": "function tax_residence_country() {a.newAttr = {a: 1} ; return data.homeAddress.legalResidenceCountry == data.taxInfo.taxResidenceCountry }",
"args": []
}
]
```

The parameter `schema` does not resovle $ref. Is there a way to resolve the $ref keyword? Or some internal function can do it manually.

**Will you be able to implement it?**

Sorry, I'm not a professional ts developer.

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

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

評価

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

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

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