ajv-validator / ajv-validator/ajv-keywords

Order of operations for `transform` and custom keywords

未关闭
#390 2 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
257
派生
51
PR 合并指标
30 天内没有已合并 PR

描述

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`](https://www.npmjs.com/package/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?

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。