Skip to content

Latest commit

 

History

History
31 lines (21 loc) · 867 Bytes

README.md

File metadata and controls

31 lines (21 loc) · 867 Bytes

Delsenyoret

Validator utility class (304 bytes).

Install

npm i delsenyoret

Use

import { Validator } from "delsenyoret";

let product_name_validator = new Validator<string>("product")
   .addRule("is_string", value => typeof value === "string")
   .addRule("is_not_empty", value => value.length > 0)
   .addRule("starts_with_pattern", value => value.startsWith("sku-"));

product_name_validator.exec("sku 37db5e2d-c36c-49c0-b8bd-ca750fd9e35a"); // throws
product_name_validator.exec("sku-37db5e2d-c36c-49c0-b8bd-ca750fd9e35a"); // ok

License

Delsenyoret is distributed under the MIT license