Required validator returns true for whitespace string when docs say it should return false.
See original GitHub issueThe Docs say that the Required Validator should fail for strings that are pure whitespace:
Requires non-empty data. Checks for empty arrays and strings containing only whitespaces.
However this is not occuring. Strings containing spaces only, pass validation.
There is a test that explicitly checks for this, so either the Documentation should be updated, or the Required validator updated to strip whitespace (i.e .trim()
)
https://github.com/vuelidate/vuelidate/blob/master/test/unit/specs/validators/required.spec.js#L40
This can be seen by going to the default fiddle https://jsfiddle.net/Frizi/b5v4faqf/ and simply typing in 5 spaces.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to validate white spaces/empty spaces? [Angular 2]
I think a simple and clean solution is to use pattern validation. The following pattern will allow a string that starts with white...
Read more >Spring Validation Example - Spring MVC Form Validator
The validation method is isValid and it returns true if data is valid else it should return false. If you are new to...
Read more >Model validation in ASP.NET Core MVC | Microsoft Learn
Server-side validation considers a required string field invalid if only whitespace is entered.
Read more >validate.js
If the message is not a function and not a string it is simply returned as is. ... the wrong length (should be...
Read more >Set rules for your form - Google Docs Editors Help
Add one of the following types of questions: Short answer; Paragraph; Checkboxes. Click More More . Click Response validation. Choose the type of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello! Do you have plan to release this anytime soon? The fix has been merged two months ago.
It can be different rule like: “requiredWithTrim”