Skip to content

spec: maxLength is authorable on every field type and validated as no more than a number — maxLength: 0 and maxLength: 12.5 parse cleanly #11566

Description

@claude

Found while implementing #11431. Filed unassigned. Cannot be fixed from the driver lane — packages/spec is a different seat.

What

packages/spec/src/data/field.zod.ts declares:

maxLength: z.number().optional().describe("Max character length"),

on the base field schema. Two consequences:

  1. No shape validation..number() alone accepts 0, -5, 12.5 and Infinity. None of those is a character length, and each parses without complaint.
  2. Authorable on every type. Being on the base schema, maxLength is legal on boolean, date, lookup, autonumber, formula — types where it describes nothing that is stored.

Evidence that this is not theoretical

schema-drift.ts read a malformed bound as authoritative and planned DDL no server accepts — maxLength: 0 took the narrowing arm (0 > 255 is false) and asked for varchar(0), at severity error / category destructive, i.e. as work os migrate apply --allow-destructive should go do. Fixed on the driver side in #11431 by refusing anything that is not a positive integer, but that is a consumer defending itself against a producer that should not have emitted the value (PD #12).

The authoring forms already disagree about where the key applies, which suggests the base-schema placement was never deliberate:

  • field.form.ts shows maxLength for text / textarea / email only
  • object.form.ts shows it for text,textarea,email,url,phone,password,markdown,html,richtext

Neither list matches the other, and neither matches the base schema's "every type".

The write-time validator (packages/objectql/src/validation/record-validator.ts) enforces maxLength for text | textarea | email | url | phone | password | markdown | html | richtext | code — a third list, and the closest thing to a real answer for which types the key means something.

Direction (for triage — not prescribing)

Two separable decisions:


Generated by Claude Code

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions