UNPKG

decoval

Version:

DecoVal is a decorator-driven validation pattern that allows you to add validation rules directly to the properties of TypeScript classes, simplifying data control and increasing code readability and reusability.

12 lines (11 loc) 474 B
import { ValidationError } from "../dv/error/validation.error"; import { registerValidation } from "../dv/register.validation"; export function LowerCase(message) { return (target, key) => { registerValidation(target, key, (value) => { if (typeof value !== "string" || value !== value.toLowerCase()) { throw new ValidationError(message || `A propriedade "${key}" deve estar em letras menusculas.`); } }); }; }