What JSON key-value input will pass validation if my schema specifies oneOf ("type" : "null" and "type" : "number") ? #592
Unanswered
GaryRoussak
asked this question in
Q&A
Replies: 3 comments
-
Hello. Thanks for your question. Can you include the schema in your question as opposed to the title pleaes? =] |
Beta Was this translation helpful? Give feedback.
0 replies
-
It should be You can see this working here: https://jsonschema.dev/s/56J4F |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks Ben, that’s perfect – all I needed.
Regards
Gary Roussak
Senior Software Engineer
Forest Rock Systems Ltd | Charnwood Building | Holywell Park | Loughborough University | Ashby Road |
Loughborough | Leicestershire | LE11 3AQ
T: 0330 660 0567 | M: 07507 800 308 | W: www.forestrock.co.uk<http://www.forestrock.co.uk/> | E: ***@***.******@***.***>
***@***.***
From: Ben Hutton ***@***.***>
Sent: Thursday, January 25, 2024 2:52 PM
To: json-schema-org/community ***@***.***>
Cc: Gary Roussak ***@***.***>; Author ***@***.***>
Subject: Re: [json-schema-org/community] What JSON key-value input will pass validation if my schema specifies oneOf ("type" : "null" and "type" : "number") ? (Discussion #592)
Caution: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
It should be
{"port": null}
You can see this working here: https://jsonschema.dev/s/56J4F
—
Reply to this email directly, view it on GitHub<#592 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AHGMPJE3FZPPLVSPQXN75G3YQJWSVAVCNFSM6AAAAABCKNYOUOVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DENBVHE4TA>.
You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I've picked up an old buggy project where { "port" : "NULL" } is being failed by a JSON-Schema validator that expects the port key to have a number or be null. I completely understand why this is failing. "NULL" is not a number, and it is not null ! I realise therefore that the code generating the JSON in this case is at fault.
I don't want to change the validator. Furthermore, the "port" value is actually null and needs to stay that way. But how do I represent the port value in JSON for it to pass validation ?
Should it be:
{ "port" : "null" }
or
{ "port" : null }
Thanks
Beta Was this translation helpful? Give feedback.
All reactions