-
Notifications
You must be signed in to change notification settings - Fork 18
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
Incorrect problem schema and error message and error type returned for array element validation #37
Comments
Hello @AdityaMandhare [
{
"firstName": "Doe",
"lastName": "John",
"type": "Distributor"
}
] And validated it against your schema. The validation produces the following error messages:
It looks good for me considering what your schema says. What error messages are you expecting? |
@leadpony in case where the array contains However, now if there is only |
@AdityaMandhare [
{
"firstName": "Doe",
"lastName": "John",
"type": "Distributor"
},
{
"firstName": "Doe",
"lastName": "Jane",
"type": "Distributor"
}
] The validator produces messages as follows.
Please note that the first 3 lines come from the first [
{
"firstName": "Doe",
"lastName": "John",
"type": "Distributor"
}
] The validator produces messages as follows.
Do you expect the following messages?
Please note that the 2nd and 3rd lines come from the first The current validator implementation omits the lines |
@leadpony it is more about the error
When there is
I expect the same error field to be pointed to and the problem schema to be returned whether there is |
@AdityaMandhare |
In Justify, each problem returned can be a tree of problems if there exist multiple solutions for the problem. |
@leadpony thanks for the info on leaf problems. However, I would still say that the root problem schema in case of
and the root error field should still be |
@AdityaMandhare |
Thanks @leadpony 🙂Always appreciate your quick response! |
@AdityaMandhare |
I have the following JSON schema in which I am trying to validate that customer types
Manufacturer
andRetailer
exist.This works fine if the array contains either
0
,2
or more elements (customer objects). However, if the array only contains1
element (customer object) of any type sayDistributor
then instead of returning a validation error againstcontains
keyword it returns a validation againstconst
keyword with error messages"The value must be constant string "Manufacturer."
and"The value must be constant string "Retailer."
with error fieldtype
. So basically instead of pointing out the missing customer typesManufacturer
andReseller
it asks me to convert the customer type ofDistributor
toManufacturer
andReseller
.If the only element in the array is of type
Manufacturer
, the the returned error message will be:"The value must be constant string "Retailer."
and again pointing to thetype
field.The validation works fine against the
contains
only if we have0
or at least2
elements in the array.Say the array was empty, then it returns error message:
At least one of the following sets of problems must be resolved.
,At least one of the following sets of problems must be resolved.
one message each for the missing
Manufacturer
andRetailer
, which is good.Say we had
Manufacturer
andDistributor
, then the error message would beAt least one of the following sets of problems must be resolved.
and it points out thatRetailer
is missing which is fine.The text was updated successfully, but these errors were encountered: