-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Required validation does not seem to be getting triggered #965
Comments
Your schema isn't valid JSON, and you didn't post your input data, so it's hard to narrow down the issue. If your property is present in the input data but is null, then what you are seeing is expected behavior and I don't think the version matters. Given this schema {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"header": {
"type": "object",
"properties": {
"order": {
"type": "string"
},
"customer": {
"type": "string"
},
"customerName": {
"type": "string"
},
"orderDate": {
"type": "string"
}
},
"required": [
"order",
"customer",
"customerName",
"orderDate"
]
}
},
"required": [
"header"
]
} Test 1 Data {} Messages
Test 2 Data {
"header": {}
} Messages
Test 3 Data {
"header": {
"customer": null
}
} Messages
|
Sorry, I our schema is a little more complex and I was just trying to simplify it some. I am using SpringBoot and have mapped request objects to the JSON object. After some further expperimentation, I have now discovered that Java is setting the value of missing JSON properties to null in the mapped Java request object. I will have to see if I can change that behavior somehow. Your validator IS working as expected. Thanks for your help as it lead me to discover the real problem. |
Given @dure0520's comment, close this issue. Thanks. |
I am using the latest version 1.3.2 and validating our payload against our schema with a SpecVersion = V7
We have properties defined with "type: "string" and also as "required"
When I try to validate against a JSON payload that does not contain one of the required fields, instead of getting an error like
header.customer: is missing but it is required
we are now receiving a message that looks like
header.customer: null found, string expected
We had used an earlier version (1.0.67) and required validation was working as expected
The text was updated successfully, but these errors were encountered: