Skip to content

json

Arbitrary JSON document, edited as code and stored parsed.

Form state is the PARSED value, not its text. The editor round-trips the document through JSON.parse/JSON.stringify client-side, and the state that reaches the wire is the value itself.

A STRING is treated as a serialized document on BOTH sides — parsed on dehydrate (some editors submit their buffer verbatim) and on hydrate (MySQL and SQLite hand back json columns as text). The symmetry has one casualty: a document whose top-level value is itself a string is not representable, because storing it would make the next read parse it again. Columns that hold free text are F.code or F.textarea, not F.json.

Builder F.json(attribute: string): JsonField
Wire type key json
Class chain JsonFieldField
Detail projection code-entry
Column counterpart (not tabulatable)

Example

import { F } from '@adonia/core'

F.json('settings')
  .label('Settings')
  .rows(12)
  .rules((v) => v.object({ theme: v.enum(['light', 'dark']) }))

Props

Beyond the shared field DSL:

Prop Declared on Behaviour
rows(count: number): this JsonField Initial editor height in rows; the client’s default applies when unset.
prettify(enabled = true): this JsonField Whether the editor re-indents the document on load (default true). prettify(false) preserves whatever formatting the stored text had, which matters for documents a human maintains by hand.

Validation

Vine base: vine.any().

§11.1 mapping: vine.any().

The row is intentionally permissive — see the module note. A rules() override replaces this base entirely (handled by Field.buildValidation), which is the documented way to schema-check a json field.

Contributed by JsonField.vineSchema() in packages/core/src/schema/fields/json_field.ts. The shared modifiers (required, nullable, requiredWhen, unique, optionality) are applied on top by Field.buildValidation, and a rules() override replaces the base entirely — the validator compiler never branches on the field class.

Declared in

  • packages/core/src/schema/fields/json_field.tsJsonField
Navigation

Type to search…

↑↓ navigate↵ selectEsc close