For the complete documentation index, see llms.txt. This page is also available as Markdown.

String Types

The string type and its email and url shortcuts.

The string type validates text. It has two predefined shortcuts that are string with a built-in pattern: Email and URL.

date, time, and datetime are not string subtypes — they are their own types with their own values. See Date and Time.

For how strings are written (open, quoted, raw), see Strings.

The string family

Type
Is

string

any text

email

string validated against an email pattern

url

string validated against a URL pattern

contact: email, site: url
---
~ a@b.com, 'https://example.com'    #
~ notanemail, 'https://example.com' # ✗ invalid-email

Quote values containing : or spaces (URLs, times-of-day, "Last, First"). An unquoted https://x.com is misread because the open string ends at :.

TypeDef

A string MemberDef accepts only the options below. Any other key is invalid.

Option
Type
Description

type

string

string, email, or url. First positional value.

default

string

Value used when the member is omitted. Second positional value.

choices

array of string

Restricts the value to a fixed set. Third positional value.

pattern

string

A regular expression the value must match.

flags

string

Regex flags for pattern (e.g. i).

len

int ≥ 0

Exact length in characters.

minLen

int ≥ 0

Minimum length.

maxLen

int ≥ 0

Maximum length.

format

string

Serialization form: auto (default), regular, raw.

encloser

string

Quote character used when serializing: " (default) or '.

escapeLines

bool

Whether to escape line breaks on serialization.

optional

bool

If true, the member may be omitted. Shorthand: ? suffix.

null

bool

If true, the member may be null. Shorthand: * suffix.

len precedence. When len is set, minLen and maxLen are ignored.

Constraints

minLen / maxLen / len

pattern

A regular expression. Use a raw string (r'…') to avoid escaping backslashes.

choices

Quote choices that look like numbers or contain commas, e.g. ["19.02, 72.85"], so they are treated as strings.

Optional, nullable & defaults

Input
Result

valid text

the string

fails a constraint

invalid-* error (invalid-min-length, invalid-pattern, …)

N, nullable (*)

null

N, not nullable

null-not-allowed error

omitted, default set

the default

omitted, optional (?)

absent

omitted, required

value-required error

Use the * suffix for nullability — keyed null: is not yet honored (see below).

Implementation status (beta)

  • Keyed optional: works; keyed null: is not yet honored — use the * suffix.

See Also

Last updated

Was this helpful?