We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I am implementing conditional validation. Here is the payload.
{ "address": { "address1": "" } }
address field is optional. Sub field address1 should be required when address exists.
address
address1
Here is my checkSchema validator.
checkSchema({ "address": { isObject: { options: { strict: true }, bail: true, }, optional: true, }, "address.address1": { exists: { if: body("address").notEmpty(), } } })
This validator is working fine.
The problem is matchedData after pass validator when there isn't address in payload, address and address1 is generated.
So, I passed empty object {}. But the matchedData is following value.
{}
{ "address": { "address1": undefined } }
The matchedData should be empty object also. How can I solve it with correct validation?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I am implementing conditional validation. Here is the payload.
address
field is optional. Sub fieldaddress1
should be required whenaddress
exists.Here is my checkSchema validator.
This validator is working fine.
The problem is matchedData after pass validator when there isn't
address
in payload,address
andaddress1
is generated.So, I passed empty object
{}
. But the matchedData is following value.The matchedData should be empty object also. How can I solve it with correct validation?
The text was updated successfully, but these errors were encountered: