Skip to content

Commit

Permalink
Merge pull request #11 from MADE-Apps/feature/validators
Browse files Browse the repository at this point in the history
Added ContainsValidator and ValidatorMap
  • Loading branch information
jamesmcroft authored Jan 18, 2022
2 parents 4c03ace + 500b8a5 commit 2c33903
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
22 changes: 22 additions & 0 deletions MADE.Data.Validation/src/validators/ContainsValidator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { IValidator } from "./IValidator";

export class ContainsValidator implements IValidator {
key: string;
isInvalid: boolean;
isDirty: boolean;
feedbackMessage: string;
options: any[];

constructor(options: any[]) {
this.key = "BetweenValidator";
this.isInvalid = false;
this.isDirty = false;
this.feedbackMessage = `The value is not a valid option.`;
this.options = options;
}

validate(value: any): void {
this.isInvalid = this.options.indexOf(value) === -1;
this.isDirty = true;
}
}
5 changes: 5 additions & 0 deletions MADE.Data.Validation/src/validators/IValidatorMap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ValidatorArray } from "./ValidatorArray";

export interface IValidatorMap {
[key: string]: ValidatorArray;
}
4 changes: 3 additions & 1 deletion MADE.Data.Validation/src/validators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ export * from './RegexValidator';
export * from './AlphaNumericValidator';
export * from './AlphaValidator';
export * from './BetweenValidator';
export * from './ContainsValidator';
export * from './EmailValidator';
export * from './IpAddressValidator';
export * from './MaxLengthValidator';
export * from './MaxValueValidator';
export * from './MinLengthValidator';
export * from './MinValueValidator';
export * from './RequiredValidator';
export * from './ValidatorArray';
export * from './ValidatorArray';
export * from './IValidatorMap';

0 comments on commit 2c33903

Please sign in to comment.