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
values
Versions
Describe the bug required_if fails if configuration is an Object, and the values parameter values are not strings
required_if
Expected behavior We get a validation error, even though the value 1 is in the values array
1
Demo link https://jsfiddle.net/davestewart/yknL0ph9/28/
Additional context The use-case for us is manually validating models, so inputs are NOT forms, with numbers being numbers, etc.
This causes required_if to fail as the comparator converts the value to a trimmed string:
vee-validate/src/rules/required_if.ts
Line 5 in 23fb945
A fix could be to map the array to a string as well, or do a "loose" comparison, using something like:
const required = values.some(value => value == String(target).trim())
Also, values could be optional, which would allow required_if to work if the value was just present (rather than being a specific value):
const required = !values || values.some(value => value == String(target).trim())
The text was updated successfully, but these errors were encountered:
f535616
No branches or pull requests
Versions
Describe the bug
required_if
fails if configuration is an Object, and thevalues
parameter values are not stringsExpected behavior
We get a validation error, even though the value
1
is in thevalues
arrayDemo link
https://jsfiddle.net/davestewart/yknL0ph9/28/
Additional context
The use-case for us is manually validating models, so inputs are NOT forms, with numbers being numbers, etc.
This causes
required_if
to fail as the comparator converts the value to a trimmed string:vee-validate/src/rules/required_if.ts
Line 5 in 23fb945
A fix could be to map the array to a string as well, or do a "loose" comparison, using something like:
Also,
values
could be optional, which would allowrequired_if
to work if the value was just present (rather than being a specific value):The text was updated successfully, but these errors were encountered: