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

Order of operations for transform and custom keywords #390

Open
carlo-quinonez opened this issue Oct 24, 2023 · 2 comments
Open

Order of operations for transform and custom keywords #390

carlo-quinonez opened this issue Oct 24, 2023 · 2 comments

Comments

@carlo-quinonez
Copy link

carlo-quinonez commented Oct 24, 2023

I understand that standard keywords, such as format will be run before any custom keywords, such as transform. So if we want to transform a string BEFORE validating its format, we have to use $allOf to force the order.

In my case, we're considering using transform to turn a proprietary version number format into something close to a semver, then using the semver keyword from the ajv-semver to validate and clean up the coercion.

What would determine the order?

  • The order the keywords are added to ajv
  • The order the keywords appear in the JSONSchema

Can we count on the order?

@carlo-quinonez carlo-quinonez changed the title Order of operations for transform and custom keywords Order of operations for transform and custom keywords Oct 24, 2023
@carlo-quinonez
Copy link
Author

@epoberezkin are custom keywords processed in a deterministic order?

@carlo-quinonez
Copy link
Author

@epoberezkin any thoughts?

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

1 participant