Skip to content

v

v<T>(builder, rules): T

Defined in: packages/forms/src/validate.ts:38

Attach validation rules to a Drizzle column builder.

The rules are stored on the builder’s internal config object via a Symbol, which Drizzle passes through to the built Column instance. introspectTable reads these rules back alongside schema-derived constraints (NOT NULL, text length) to produce complete FieldDefinition objects.

T extends ColumnBuilderBase<ColumnBuilderBaseConfig<ColumnDataType, string>, object>

The Drizzle column builder type, preserved for chaining.

T

A Drizzle column builder (e.g., text("title").notNull()).

ValidationRules

The ValidationRules to attach to the column.

T

The same builder instance, so it can be used inline in a table definition.

import { v } from "@cfast/forms";
import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
export const posts = sqliteTable("posts", {
title: v(text("title").notNull(), { minLength: 3, maxLength: 200 }),
views: v(integer("views"), { min: 0 }),
slug: v(text("slug").notNull(), { pattern: /^[a-z0-9-]+$/ }),
});