sagold / json-schema-library

Customizable and hackable json-validator and json-schema utilities for traversal, data generation and validation
MIT License
164 stars 19 forks source link

Type 'number' accepts null/NaN as value #23

Closed MueckeMa closed 1 year ago

MueckeMa commented 1 year ago

Hi, when validating a value of type number, null or NaN are assumed as valid value. If the type integer is validated, this error message appears:

Expected NaN (number) in # to be of type integer

Expected behavior:

When checking the type number, this error message is generated for a value of null or NaN:

Expected NaN (number) in # to be of type number

Schema

{
   type: 'number'
}

Value

null

Version: v7.3.2

sagold commented 1 year ago

Thank you for reporting this.

A fix has been published with v7.3.3 treating NaN as valid integer: https://github.com/sagold/json-schema-library/runs/9641080742#r0s23

Cheers