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.

Having validateAll throw an exception is a bad idea

See original GitHub issue

Versions:

  • VueJs: 2.3.3
  • Vee-Validate: 2.0.0-rc.3

Description:

Because the validateAll methods throws an exception, I’m forced to have .catch(() => { }) littered through my code otherwise the exception isn’t caught and I get an uncaught error. The exception isn’t interesting to me because the error messages are rendered in my template automatically using the errorBag. I shouldn’t be forced to deal with this error.

The purpose of this method is to validate all fields. It should only throw an exception if there was an unexpected problem when trying to run validation. A field not being valid isn’t an error. it’s an expected outcome. So why are people forced to have a (possibly empty) catch block in there code for expected outcomes?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Neve12ende12commented, Jul 13, 2017

@rstuart85 @logaretm

Since validateAll() returns a promise, couldn’t we use .done() and .fail() or would that present the same problem that caused you to get rid of .catch()?

1reaction
pachecodercommented, May 25, 2017
validateForm(scope) {
        this.$validator.validateAll(scope)
        .then(() => {
           alert('success')
        })
        .catch(() => { })
      }

Hi @logaretm why i get this error when i’m handling my promises?

Read more comments on GitHub >

github_iconTop Results From Across the Web

validation - Is it a good or bad idea throwing Exceptions ...
It depends - if you are expecting the data to be there and NOT having the data is unexpected, then throwing an exception...
Read more >
c# - Why is it bad to use exceptions for handling this type ...
The first issue I have with using exceptions for validation is that I would typically expect the outcome of the validation to potentially ......
Read more >
Is it a good practice to validate all method input params ...
Is it a good practice to validate all method input params and throw Argument exception? Hi,. I know this could seem a ...
Read more >
LINQ to SQL - validate all, then throw exception - MSDN - Microsoft
If I have two "interesting objects" that need to be validated, everything stops once the first entity's OnValidate() throws an exception.
Read more >
C5: Validate All Inputs
Log security deserialization exceptions and failures, such as where the incoming type is not the expected type, or the deserialization throws exceptions.
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