Skip to content

code

Source-code editor bound to a string attribute.

Unlike every other string field, code does NOT trim: leading indentation and a trailing newline are content in a source file, and a validator that quietly removed them would corrupt what the author typed.

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

Example

import { F } from '@adonia/core'

F.code('template').label('Template').language('html').rows(20).lineNumbers()

Props

Beyond the shared field DSL:

Prop Declared on Behaviour
language(name: string): this CodeField Highlighter grammar name ('sql', 'html', 'ts', …), passed through to the client editor and to the code-entry detail projection. Purely a rendering hint — the server never parses the content.
rows(count: number): this CodeField Initial editor height in rows; the client’s default applies when unset.
lineNumbers(enabled = true): this CodeField Renders a line-number gutter (default off).
wrap(enabled = true): this CodeField Soft-wraps long lines instead of scrolling horizontally (default off).

Validation

Vine base: vine.string().

§11.1 mapping: vine.string() with the declared length bounds, and deliberately no trim() — see the class note.

Contributed by CodeField.vineSchema() in packages/core/src/schema/fields/code.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/code.tsCodeField
Navigation

Type to search…

↑↓ navigate↵ selectEsc close