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
Versions
Describe the bug
We have to build up rulesets based on conditions that change at runtime, for example:
const rules = 'numeric' if (x) { rules += '|required' // rules is 'numeric|required' }
This works fine for rules where the initial condition has a validator.
But if we start with an empty string (no validation, but we may later want it to be required) we get Error: No such validator '' exists:
Error: No such validator '' exists
const rules = '' if (x) { rules += '|required' // first rule is '' }
Expected behavior
As there could be quite complex conditions to when we build the rules, it would be useful if the "empty" rule was simply ignored:
const rulesIn = 'numeric||min:0||||max:100||' const rulesOut = 'numeric|min:0|max:100'
The rules could be easily filtered using a function, but should this filtering be built into the library?
Demo link
Additional context
I also wrote a function which converted all rules to objects but this felt like overkill for many of our much simpler rulesets.
The text was updated successfully, but these errors were encountered:
|
Would be worth looking at this in conjunction with #2388
Sorry, something went wrong.
fix: allow empty rules (pipes) in string rules closes #2386
47b95a5
fix: allow empty rules (pipes) in string rules closes #2386 (#2389)
94d09d6
Successfully merging a pull request may close this issue.
Versions
Describe the bug
We have to build up rulesets based on conditions that change at runtime, for example:
This works fine for rules where the initial condition has a validator.
But if we start with an empty string (no validation, but we may later want it to be required) we get
Error: No such validator '' exists
:Expected behavior
As there could be quite complex conditions to when we build the rules, it would be useful if the "empty" rule was simply ignored:
The rules could be easily filtered using a function, but should this filtering be built into the library?
Demo link
Additional context
I also wrote a function which converted all rules to objects but this felt like overkill for many of our much simpler rulesets.
The text was updated successfully, but these errors were encountered: