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

[question] can you use ajv-formats with ajv@6.12.6 ? #26

Open
linfanxxxx opened this issue Apr 22, 2021 · 2 comments
Open

[question] can you use ajv-formats with ajv@6.12.6 ? #26

linfanxxxx opened this issue Apr 22, 2021 · 2 comments

Comments

@linfanxxxx
Copy link

please,i need format: int 32 , bug ajv don't include

@seriousme
Copy link
Contributor

Version 2.1.0 will include int32, see #22 and #25.
Until then you can add:

const MIN_INT32 = -(2 ** 31)
const MAX_INT32 = 2 ** 31 - 1

function validateInt32(value) {
  return Number.isInteger(value) && value <= MAX_INT32 && value >= MIN_INT32
}

ajv.addFormat("int32", {type: "number", validate: validateInt32})

@epoberezkin
Copy link
Member

I am wondering if it would work with 6.12.6... You can definitely require just the format definition out of it and add manually.

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

3 participants