Skip to content

Commit 2c33903

Browse files
authored
Merge pull request #11 from MADE-Apps/feature/validators
Added ContainsValidator and ValidatorMap
2 parents 4c03ace + 500b8a5 commit 2c33903

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { IValidator } from "./IValidator";
2+
3+
export class ContainsValidator implements IValidator {
4+
key: string;
5+
isInvalid: boolean;
6+
isDirty: boolean;
7+
feedbackMessage: string;
8+
options: any[];
9+
10+
constructor(options: any[]) {
11+
this.key = "BetweenValidator";
12+
this.isInvalid = false;
13+
this.isDirty = false;
14+
this.feedbackMessage = `The value is not a valid option.`;
15+
this.options = options;
16+
}
17+
18+
validate(value: any): void {
19+
this.isInvalid = this.options.indexOf(value) === -1;
20+
this.isDirty = true;
21+
}
22+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { ValidatorArray } from "./ValidatorArray";
2+
3+
export interface IValidatorMap {
4+
[key: string]: ValidatorArray;
5+
}

MADE.Data.Validation/src/validators/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ export * from './RegexValidator';
44
export * from './AlphaNumericValidator';
55
export * from './AlphaValidator';
66
export * from './BetweenValidator';
7+
export * from './ContainsValidator';
78
export * from './EmailValidator';
89
export * from './IpAddressValidator';
910
export * from './MaxLengthValidator';
1011
export * from './MaxValueValidator';
1112
export * from './MinLengthValidator';
1213
export * from './MinValueValidator';
1314
export * from './RequiredValidator';
14-
export * from './ValidatorArray';
15+
export * from './ValidatorArray';
16+
export * from './IValidatorMap';

0 commit comments

Comments
 (0)