From e79d72501e9091f9a979c310d8258b0e058f69b2 Mon Sep 17 00:00:00 2001 From: Vitor Veras Date: Sat, 30 Jan 2021 11:55:39 -0300 Subject: [PATCH] feat: ensure EmailValidation returns InvalidFieldError with email message --- .../validators/email-validation/email-validation.ts | 10 ++++++++++ src/validation/validators/index.ts | 1 + 2 files changed, 11 insertions(+) create mode 100644 src/validation/validators/email-validation/email-validation.ts diff --git a/src/validation/validators/email-validation/email-validation.ts b/src/validation/validators/email-validation/email-validation.ts new file mode 100644 index 0000000..52f4359 --- /dev/null +++ b/src/validation/validators/email-validation/email-validation.ts @@ -0,0 +1,10 @@ +import {InvalidFieldError} from '@/validation/errors'; +import {FieldValidation} from '@/validation/protocols'; + +export class EmailValidation implements FieldValidation { + constructor(readonly field: string) {} + validate(value: string): Error { + console.log(value); + return new InvalidFieldError('email'); + } +} diff --git a/src/validation/validators/index.ts b/src/validation/validators/index.ts index fbb9de2..5b98390 100644 --- a/src/validation/validators/index.ts +++ b/src/validation/validators/index.ts @@ -1 +1,2 @@ +export * from './email-validation/email-validation'; export * from './required-field/required-field-validation';