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

Zod · all subjects

schema definitions/template literals

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

Template literal schemas introduced in Zod 4

Introduced in zod@4.0. Use z.templateLiteral([...]) to define template literal schemas. Pass an array alternating string literals and schemas. Any schema with inferred type assignable to string | number | bigint | boolean | null | undefined can be used. Examples: z.templateLiteral(['hello, ', z.string(), '!']) for `hello, ${string}!`, z.templateLiteral([z.number(), z.enum(['px', 'em', 'rem'])]) for `${number}px` | `${number}em` | `${number}rem`.

z.templateLiteral() for template literal types

z.templateLiteral() represents TypeScript template literal types. Each element is a schema or string literal. Example: z.templateLiteral(['hello, ', z.string()]) represents `hello, ${string}`. Template literal types concatenate internal regexes of stringifiable types (strings, formats, numbers, booleans, bigints, enums, literals, optionals, nullables, other template literals).

z.templateLiteral() example with number and enum

const cssUnits = z.enum(['px', 'em', 'rem', '%']); const css = z.templateLiteral([z.number(), cssUnits]); produces types: `${number}px` | `${number}em` | `${number}rem` | `${number}%`

z.templateLiteral() enforces string format refinements

Template literals enforce string format refinements. Example: z.templateLiteral([z.string().min(1), '@', z.string().max(64)]) represents `${string}@${string}` where min/max constraints are enforced, but custom refinements are not.

Give your agent this brain