Skip to content

Commit

Permalink
feat: add validation layer protocols FieldValidation and Validation
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorverasm committed Jan 30, 2021
1 parent 5ec7751 commit 246a59a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/validation/errors/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './required-field-error';
8 changes: 8 additions & 0 deletions src/validation/errors/required-field-error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {ErrorsI18n, translate} from '@/locale';

export class RequiredFieldError extends Error {
constructor() {
super(translate(ErrorsI18n.requiredFieldError));
this.name = 'RequiredFieldError';
}
}
4 changes: 4 additions & 0 deletions src/validation/protocols/filed-validation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface FieldValidation {
field: string;
validate(value: string): Error;
}
2 changes: 2 additions & 0 deletions src/validation/protocols/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './filed-validation';
export * from './validation';

0 comments on commit 246a59a

Please sign in to comment.