Aphex
Schema Types

Number

Numeric input for integers and decimal values.

The number type stores numeric values. Supports both integers and decimals.

Definition

import type { NumberField } from '@aphexcms/cms-core';
{
  name: 'price',
  type: 'number',
  title: 'Price',
  validation: (Rule) => Rule.required().positive()
}

Properties

PropertyTypeRequiredDescription
namestringYesField identifier.
type'number'YesMust be 'number'.
titlestringYesLabel shown in the admin UI.
descriptionstringNoHelp text shown below the label. Also used as placeholder text if provided.
initialValuenumber | () => number | Promise<number>NoDefault value.
validation(Rule) => RuleNoValidation rules.

The type definition also includes min and max properties. These are reserved for future use and are not yet applied as HTML input constraints by the component. Use validation rules instead.

Examples

Integer field

{
  name: 'quantity',
  type: 'number',
  title: 'Quantity',
  validation: (Rule) => Rule.required().integer().positive()
}

Constrained range

{
  name: 'rating',
  type: 'number',
  title: 'Rating',
  validation: (Rule) => Rule.required().min(1).max(5).integer()
}

Decimal values

{
  name: 'price',
  type: 'number',
  title: 'Price',
  initialValue: 0,
  validation: (Rule) => Rule.required().positive()
}

Validation

Available rules: required(), min(value), max(value), positive(), negative(), integer(), greaterThan(num), lessThan(num), custom(fn), error(msg), warning(msg), info(msg)

Edit on GitHub

Last updated on