class-validator icon indicating copy to clipboard operation
class-validator copied to clipboard

question: option to define dependencies between validators

Open twittwer opened this issue 8 years ago • 7 comments

Is there an option to define dependencies between validators? My use case is an custom validator for an email. It shouldn't run if the IsEmail validation failed.

@IsEmail()
@IsUnique()
email: string;

Thank you in advance :)

twittwer avatar Nov 05 '17 17:11 twittwer

Hi @twittwer!

No, there is currently no option to do this, all validation rules will be triggered on every property, regardless of the result of the previous ones.

NoNameProvided avatar Jan 08 '18 07:01 NoNameProvided

I have implemented it here. Incidentally this project could probably delegate to https://github.com/fireflysemantics/is as I am doing.

oleersoy avatar Jul 19 '18 14:07 oleersoy

No need to delegate it, it will be implemented in the core.

NoNameProvided avatar Jul 19 '18 15:07 NoNameProvided

I broke it off into a completely separate module and updated the Typedoc. Obviously you are free to keep it in the core.

https://www.npmjs.com/package/@fireflysemantics/is

oleersoy avatar Jul 20 '18 04:07 oleersoy

@NoNameProvided is the library still in development? I really like the typestack libraries, but they look dead as for now.

bohdan-shulha avatar Jan 03 '19 13:01 bohdan-shulha

I implemented the feature asked for here: https://www.npmjs.com/package/@fireflysemantics/validator

oleersoy avatar Jan 03 '19 22:01 oleersoy

+1 this feature is needed please

abdelrahman543873 avatar May 16 '22 23:05 abdelrahman543873

+1 this feature is needed please

Set stopAtFirstError: true on ValidationPipe and set validations in reverse manner

tje3d avatar Nov 14 '22 12:11 tje3d