talendcomp_tJSONDoc icon indicating copy to clipboard operation
talendcomp_tJSONDoc copied to clipboard

Json Schema validator can't find the type mismatch error with sting in INT field

Open blag001 opened this issue 5 years ago • 7 comments

Hello, I'm using the 16.2 build and encounter a bug : When using this simple Json schema

{
  "type": "object",
  "properties": {
    "ID": {
      "type": "integer"
    }
  }
}

I'm able to validate this JSON : {"ID" : "2"}

But as explained here https://json-schema.org/understanding-json-schema/reference/numeric.html#integer the sting "2" should not be valid.

I think it's a bug in the validator engine, did you know if there is a way to patch it ? Thank in advance, Bests Regards

blag001 avatar Sep 11 '20 12:09 blag001

This is intentionally done because a lot of documents are not that strict in using " only for text values.

jlolling avatar Oct 08 '20 13:10 jlolling

Understood, but sadly we use strict typing... (and same go for online Json validator).

Maybe adding a checkbox to enable a "strict type" on the Json schema check (used on tOpen & tSave if I remember) ?

blag001 avatar Oct 19 '20 15:10 blag001

I will check the current implementation and try to use optional a more strict method.

jlolling avatar Oct 19 '20 15:10 jlolling

Hello Jan, Did you have any update on this problem ? It's still bothering us a lot sadly :/

I take a look, so far it seem it's this line https://github.com/jlolling/talendcomp_tJSONDoc/blob/master/src/main/java/de/jlo/talendcomp/json/TypeUtil.java#L188 But I'm not confident enough to try messing around... Kinds regards

blag001 avatar Sep 22 '21 09:09 blag001

Indeed, I was distracted from solving this issue. I will check that this week.

jlolling avatar Sep 22 '21 09:09 jlolling

I need to update the validation engine and the idea is to create a dedicated component for validating.

jlolling avatar Sep 22 '21 10:09 jlolling

I am going to introduce a new validation engine. I hope this new version will solve you issue.

jlolling avatar Nov 16 '21 22:11 jlolling