Overview#
Regist is a declarative, type-safe, and human readable library for string validation and transformation. It is syntax sugar for regex, so you write checks in plain chains instead of patterns full of slashes and escapes.
Installation#
Install it with npm install @regist/regist.
How It Works#
There are two APIs. assertThat checks a string, and stringTransform changes one. For example, assertThat("foo@bar.com").isEmail().try() returns true.
It also works alongside zod. A username check can sit inside a zod schema, so you keep zod for the structure and Regist for the string rules.
Core Principles#
- Readable: the string logic looks like what you mean.
- Chainable: every method returns the API, so checks compose easily.
- Reusable: chains are lazy, so you can build one and reuse it.