ajv icon indicating copy to clipboard operation
ajv copied to clipboard

Cannot serialize and then parse int32 type

Open eikooc opened this issue 1 year ago • 1 comments

What version of Ajv are you using? Does the issue happen if you use the latest version?

Using version 8.11.0

Ajv options object

const ajv = new Ajv()

JSON Schema

{
  "properties": {
    "foo": { "type": "int32" }
  }
}

Sample data

{}

Your code

const serialize = ajv.compileSerializer(schema)
const parser = ajv.compileParser(schema)
const data = parser(serialize({}))

What results did you expect?

// data to be:
// {
//   foo: undefined
// }

But got:

// data is:
// undefined

eikooc avatar Sep 23 '22 12:09 eikooc

"int32" is not a valid json schema type.

GabenGar avatar Oct 13 '22 01:10 GabenGar

@GabenGar I've updated the header to read "JSON Type Definition (JTD)" to avoid confusion. It should be a valid JTD.

eikooc avatar Oct 25 '22 05:10 eikooc