stringColumnToSchema() — drizzle-orm Function Reference
Architecture documentation for the stringColumnToSchema() function in column.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 9ce7dd2e_3029_ff13_c7f5_a5bcb7c9349d["stringColumnToSchema()"] 04df2f9f_a1ec_55a9_5392_86b92a0e6555["column.ts"] 9ce7dd2e_3029_ff13_c7f5_a5bcb7c9349d -->|defined in| 04df2f9f_a1ec_55a9_5392_86b92a0e6555 c3d8e5a3_48ae_8877_650c_206534a04c0c["columnToSchema()"] c3d8e5a3_48ae_8877_650c_206534a04c0c -->|calls| 9ce7dd2e_3029_ff13_c7f5_a5bcb7c9349d style 9ce7dd2e_3029_ff13_c7f5_a5bcb7c9349d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-valibot/src/column.ts lines 243–296
function stringColumnToSchema(column: Column): v.GenericSchema {
if (isColumnType<PgUUID<ColumnBaseConfig<'string', 'PgUUID'>>>(column, ['PgUUID'])) {
return v.pipe(v.string(), v.uuid());
}
let max: number | undefined;
let regex: RegExp | undefined;
let fixed = false;
if (isColumnType<PgVarchar<any> | SQLiteText<any>>(column, ['PgVarchar', 'SQLiteText'])) {
max = column.length;
} else if (
isColumnType<MySqlVarChar<any> | SingleStoreVarChar<any>>(column, ['MySqlVarChar', 'SingleStoreVarChar'])
) {
max = column.length ?? CONSTANTS.INT16_UNSIGNED_MAX;
} else if (isColumnType<MySqlText<any> | SingleStoreText<any>>(column, ['MySqlText', 'SingleStoreText'])) {
if (column.textType === 'longtext') {
max = CONSTANTS.INT32_UNSIGNED_MAX;
} else if (column.textType === 'mediumtext') {
max = CONSTANTS.INT24_UNSIGNED_MAX;
} else if (column.textType === 'text') {
max = CONSTANTS.INT16_UNSIGNED_MAX;
} else {
max = CONSTANTS.INT8_UNSIGNED_MAX;
}
}
if (
isColumnType<PgChar<any> | MySqlChar<any> | SingleStoreChar<any>>(column, [
'PgChar',
'MySqlChar',
'SingleStoreChar',
])
) {
max = column.length;
fixed = true;
}
if (isColumnType<PgBinaryVector<any>>(column, ['PgBinaryVector'])) {
regex = /^[01]+$/;
max = column.dimensions;
}
const actions: any[] = [];
if (regex) {
actions.push(v.regex(regex));
}
if (max && fixed) {
actions.push(v.length(max));
} else if (max) {
actions.push(v.maxLength(max));
}
return actions.length > 0 ? v.pipe(v.string(), ...actions) : v.string();
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does stringColumnToSchema() do?
stringColumnToSchema() is a function in the drizzle-orm codebase, defined in drizzle-valibot/src/column.ts.
Where is stringColumnToSchema() defined?
stringColumnToSchema() is defined in drizzle-valibot/src/column.ts at line 243.
What calls stringColumnToSchema()?
stringColumnToSchema() is called by 1 function(s): columnToSchema.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free