Having validateAll throw an exception is a bad idea
See original GitHub issueVersions:
- 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:
- Created 6 years ago
- Comments:10 (7 by maintainers)
Top 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 >
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
@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()?
Hi @logaretm why i get this error when i’m handling my promises?