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.
Type Parameters
Section titled “Type Parameters”T extends ColumnBuilderBase<ColumnBuilderBaseConfig<ColumnDataType, string>, object>
The Drizzle column builder type, preserved for chaining.
Parameters
Section titled “Parameters”builder
Section titled “builder”T
A Drizzle column builder (e.g., text("title").notNull()).
The ValidationRules to attach to the column.
Returns
Section titled “Returns”T
The same builder instance, so it can be used inline in a table definition.
Example
Section titled “Example”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-]+$/ }),});