diff --git a/src/db/Validator.ts b/src/db/Validator.ts index e76ed9a..85ca6b8 100644 --- a/src/db/Validator.ts +++ b/src/db/Validator.ts @@ -86,6 +86,30 @@ export default class Validator { return this; } + /** + * @param minLength included + */ + public minLength(minLength: number): Validator { + this.addStep({ + verifyStep: val => (val).length >= minLength, + throw: () => new BadLengthValidationError(minLength, 1000000), + isFormat: true, + }); + return this; + } + + /** + * @param maxLength included + */ + public maxLength(maxLength: number): Validator { + this.addStep({ + verifyStep: val => (val).length <= maxLength, + throw: () => new BadLengthValidationError(0, maxLength), + isFormat: true, + }); + return this; + } + /** * @param minLength included * @param maxLength included