Skip to content
New issue

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

Shouldn't the required check be performed first of all? #602

Closed
joaogn opened this issue Aug 17, 2019 · 2 comments
Closed

Shouldn't the required check be performed first of all? #602

joaogn opened this issue Aug 17, 2019 · 2 comments

Comments

@joaogn
Copy link

joaogn commented Aug 17, 2019

I saw it in the Issues #256 #499 #503.
I have the same problem when executing a .test (value), I have the error that the value is undefined, it happens because the tests are all done in parallel, and I think this has to be maintained, but this can cause some problems, Sequential checks are a good solution as said in these Issues but losing performance and can be costly to develop.

But I think a more efficient solution would be to run .required () before any other check, because if the variable doesn't exist you don't have to run everything in parallel and still solve the problems mostly of .test ()

@jquense
Copy link
Owner

jquense commented Aug 29, 2019

I've considered this a few times, for most cases it'd be slightly simple to write tests, however there isn't any reason that all custom tests would want to only operate on present values, for instance if you wanted to differentiate between null and undefined. It's annoying to have to check in every test but not so much so i think that we need to avoid it. We can maybe make it configurable but idk if that's worth the effort

@jquense jquense closed this as completed Aug 29, 2019
@joaogn
Copy link
Author

joaogn commented Aug 29, 2019

The issue is not the job of checking each item in the test, but of the return of validation.

Example: I go to the test and check if it is undefined, then it will return me the error of the test, but in fact the error is isRequired.

Another solution would be, I have how to write the error return in the test check, for example if undefined I write an isRequired error, if it is not undefined and not passed I write the test error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants