ajv-keywords icon indicating copy to clipboard operation
ajv-keywords copied to clipboard

Typeof bigint

Open zdm opened this issue 3 years ago • 4 comments

Could you please add bigint to the typeof keyword?

zdm avatar Jan 31 '22 23:01 zdm

I think it would require adding bigint support to ajv... It could potentially be limited just to this keyword, if you make the PR we can assess if it is ok as an isolated change.

epoberezkin avatar Feb 04 '22 18:02 epoberezkin

Why? typeof just checks types, without coercions or other things. I think it will be enough to add bigint here:

const TYPES = ["undefined", "string", "number", "object", "function", "boolean", "symbol"]

zdm avatar Feb 05 '22 05:02 zdm

Why?

well, because none of the keywords you expect to work with integer would work with bigint... Also, it seems to have a limited utility as JSON.parse cannot be configured to parse as bigint.

But I don't mind adding it to typeof here only, with the disclaimer in the docs that none of the other keywords that apply to numbers/integers apply to bigint...

epoberezkin avatar May 20 '22 06:05 epoberezkin

I will come back to this issue a bit later.

On 20.05.2022 09:42, Evgeny Poberezkin wrote:

Why?

well, because none of the keywords you expect to work with integer would work with bigint... Also, it seems to have a limited utility as JSON.parse cannot be configured to parse as bigint.

But I don't mind adding it to typeof here only, with the disclaimer in the docs that none of the other keywords that apply to numbers/integers apply to bigint...

— Reply to this email directly, view it on GitHub https://github.com/ajv-validator/ajv-keywords/issues/251#issuecomment-1132531945, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2MSGKWYQGC2R25B4ACHDVK4X3RANCNFSM5NHT5JJQ. You are receiving this because you authored the thread.Message ID: @.***>

zdm avatar May 20 '22 07:05 zdm

Noy actually needed. we decided to not use biginy at all

zdm avatar Feb 21 '24 20:02 zdm