Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transfom: ['trim'] becomes empty after compile #219

Open
rucebee opened this issue Sep 25, 2021 · 2 comments
Open

transfom: ['trim'] becomes empty after compile #219

rucebee opened this issue Sep 25, 2021 · 2 comments

Comments

@rucebee
Copy link

rucebee commented Sep 25, 2021

Not sure this is ajv-keywords bug or ajv itself, or even this is a bug of a feature))
But it was very tricky to find out why transform trim sometimes doesn't work

It turns that ajv.compile spoils my userSchema after first call and array items are vanished

"ajv": "^8.6.3",
"ajv-keywords": "^5.0.0",

    console.log(JSON.stringify(userSchema))
//{"type":"object","properties":{"id":{"type":"string","allOf":[{"transform":["trim"] ...

    ajv.compile(userSchema)

    console.log(JSON.stringify(userSchema))
//{"type":"object","properties":{"id":{"type":"string","allOf":[{"transform":[]...

    const validate = ajv.compile(userSchema)

This is not expected behavior

@rucebee
Copy link
Author

rucebee commented Sep 25, 2021

should I use deep clone for schemas to avoid this? or is there any better solution?

@epoberezkin
Copy link
Member

I need to reproduce - looks like it’s a big, should be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants