new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Drizzle · SQLite · all subjects

arktype/refinements

3 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Schema refinements extend or overwrite fields

Each create schema function (createSelectSchema, createInsertSchema, createUpdateSchema) accepts an optional second parameter for refinements. When you pass a callback function, it extends or modifies the field's schema. When you pass an arktype schema directly, it overwrites the field's schema completely, including its nullability.

Schema refinements example with extensions and overwrites

Example showing schema refinements that extend, modify, or overwrite fields: import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'; import { createSelectSchema } from 'drizzle-orm/arktype'; import { ArkErrors, type } from 'arktype'; const users = sqliteTable('users', { id: integer().primaryKey({ autoIncrement: true }), name: text().notNull(), bio: text(), preferences: text({ mode: 'json' }) }); const userSelectSchema = createSelectSchema(users, { name: (schema) => schema.atMostLength(20), bio: (schema) => type.string.atMostLength(2000), preferences: type({ theme: 'string' }) }); const parsed: ArkErrors | { id: number; name: string, bio: string | null; preferences: { theme: string; }; } = userSelectSchema(...);

Schema refinements with callback functions or Typebox schemas

Each create schema function (createSelectSchema, createInsertSchema, createUpdateSchema) accepts an optional second parameter for refinements. Providing a callback function extends or modifies a field's schema. Providing a Typebox schema directly overwrites the field's schema entirely, including its nullability settings. For example, a callback can add maxLength constraints while preserving nullability, but a full schema replacement will override those settings.

Give your agent this brain