You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there any way to stop all validations when a check fails ?
Take a look at this example:
login(){// Messages in PT-BR, nothing important...return[cookie('token').custom((theToken)=>!this.#verifyUserToken(theToken)).bail().withMessage('Não é preciso se autenticar pois o usuário já está autenticado'),body('email').isString().withMessage('O e-mail precisa ser uma string').notEmpty().withMessage('O e-mail não pode ser vazio').isEmail().withMessage('É necessário um e-mail válido'),body('password').isString().withMessage('A senha precisa ser do tipo string').notEmpty().withMessage('A senha é um campo necessário para o login')];}
I know that the .bail() can stop the cascade validation, but looks like that it only stops for the same check.
The problem is that is really unnecessary report any email or password fail if the user is already logged.
The login is the least complicated, the register validations is also using external database queries, and if the user is already logged, there's no sense of doing everything for just report that the token is valid and a lot of another useless stuff.
I searched the repository's issues and i found a similar question #696, such question that was marked as duplicated of a issue that discuss about the .bail() and no useful information about this kind of problem.
My final question is: Is there any way for stop all the next validations on a validation fail? if not, is there a different approach that i a can get the same expected results?
Thank you for the help!
The text was updated successfully, but these errors were encountered:
Is there any way to stop all validations when a check fails ?
Take a look at this example:
I know that the .bail() can stop the cascade validation, but looks like that it only stops for the same check.
The problem is that is really unnecessary report any email or password fail if the user is already logged.
The login is the least complicated, the register validations is also using external database queries, and if the user is already logged, there's no sense of doing everything for just report that the token is valid and a lot of another useless stuff.
I searched the repository's issues and i found a similar question #696, such question that was marked as duplicated of a issue that discuss about the .bail() and no useful information about this kind of problem.
My final question is: Is there any way for stop all the next validations on a validation fail? if not, is there a different approach that i a can get the same expected results?
Thank you for the help!
The text was updated successfully, but these errors were encountered: