question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Required validator returns true for whitespace string when docs say it should return false.

See original GitHub issue

The 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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
noldecommented, Jun 24, 2019

Hello! Do you have plan to release this anytime soon? The fix has been merged two months ago.

0reactions
mbaevcommented, Jun 2, 2020

It can be different rule like: “requiredWithTrim”

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found