ajv-validator / ajv-validator/ajv-keywords

Transform (trim) on nested objects via definitions is not working

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

Mô tả

Hello!

I have found interesting behavior of transform keyword, which is probably a bug.
In short: `"transform": [ "trim" ]` is not working on nested objects if specified via definitions.

The schema:
```
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"trimmedString": {
"type": "string",
"transform": ["trim"]
}
},
"type": "object",
"properties": {
"a": {
"$ref": "#/definitions/trimmedString"
},
"nested": {
"type": "object",
"properties": {
"b": {
"$ref": "#/definitions/trimmedString"
},
"c": {
"type": "string",
"transform": ["trim"]
}
}
}
}
}
```

Input data:
```
{
"a": " x ",
"nested": {
"b": " y ",
"c": " z "
}
}
```

Expected results: all strings are trimmed.

Actual results: string `b` in nested objects is not trimmed
```
{
"a": "x",
"nested": {
"b": " y ",
"c": "z"
}
}
```

My versions:
```
"ajv": "^7.0.3",
"ajv-formats": "^1.5.1",
"ajv-keywords": "^4.0.0",
```

Thanks!

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.