Regist

0 views

Problem

Regular expressions are powerful, but they are hard to read, easy to get wrong, and difficult for teammates to maintain.

Core Idea

A declarative, human readable syntax on top of regex. You write string checks and transformations as chains which read like plain English.

Guarantees

Chains are lazy and reusable, so a check can be built once and used in many places.

Tradeoffs

Regist is not a regex engine or a schema validation library. It sits on top of regex and works alongside tools like zod.

regextypescriptvalidationopen-source

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.