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

Decimal

The decimal type — fixed-precision decimal numbers.

The decimal type validates an exact, fixed-precision decimal — for money and other values where binary floating point would lose accuracy. In data it is written with an m suffix: 123.45m.

For the literal syntax, see Decimal values.

TypeDef

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

Option
Type
Description

type

string

The type name decimal. First positional value.

default

decimal

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

choices

array of decimal

Restricts the value to a fixed set.

precision

int

Maximum total number of significant digits.

scale

int

Exact number of digits after the decimal point.

min

decimal

Minimum allowed value (inclusive).

max

decimal

Maximum allowed value (inclusive).

multipleOf

decimal

The value must be an exact multiple of this.

optional

bool

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

null

bool

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

Precision & scale

precision and scale together give SQL-style DECIMAL(precision, scale) validation:

  • scale — the number of fractional digits MUST equal scale.

  • precision — the total significant digits MUST NOT exceed precision.

With neither precision nor scale, a decimal is compared by its exact value.

Optional, nullable & defaults

Resolution follows the common rules:

Implementation status (beta)

  • Keyed null: is not yet honored — use the * suffix.

See Also

Last updated

Was this helpful?