Skip to content

ValidationRules

ValidationRules = object

Defined in: packages/forms/src/types.ts:19

Validation rules that can be attached to a Drizzle column via the v helper.

These rules are stored as metadata on the column builder and read back by introspectTable to generate client-side validation via createResolver.

import { v } from "@cfast/forms";
import { text, integer } from "drizzle-orm/sqlite-core";
const title = v(text("title").notNull(), { minLength: 3, maxLength: 200 });
const views = v(integer("views"), { min: 0, message: "Views cannot be negative" });

optional max: number

Defined in: packages/forms/src/types.ts:27

Maximum numeric value. Applied to number inputs.


optional maxLength: number

Defined in: packages/forms/src/types.ts:23

Maximum string length. Applied to text/varchar inputs.


optional message: string

Defined in: packages/forms/src/types.ts:31

Custom error message displayed when any rule fails. Overrides the auto-generated message.


optional min: number

Defined in: packages/forms/src/types.ts:25

Minimum numeric value. Applied to number inputs.


optional minLength: number

Defined in: packages/forms/src/types.ts:21

Minimum string length. Applied to text/varchar inputs.


optional pattern: RegExp

Defined in: packages/forms/src/types.ts:29

Regex pattern the string value must match.