number
number<
TFieldMeta>(options?):NumberField<TFieldMeta>
Defined in: packages/core/src/fields/number/config.ts:49
Creates a number field with all defaults applied.
Number fields store numeric values. Common uses: prices, quantities, ratings, ages, counts.
Accepts NumberFieldInput (all optional) and returns NumberField with all defaults applied.
Defaults applied:
label—""(inferred from the field key bydefineCollection)required—falseadmin.hidden—falseadmin.readOnly—falseadmin.position—"main"admin.width—"full"admin.cellAlignment—"left"
Type Parameters
Section titled “Type Parameters”TFieldMeta
Section titled “TFieldMeta”TFieldMeta extends object = { }
Parameters
Section titled “Parameters”options?
Section titled “options?”NumberFieldInput<TFieldMeta>
Number field configuration. All properties are optional.
Returns
Section titled “Returns”NumberField<TFieldMeta>
Resolved number field definition with all defaults applied.
Example
Section titled “Example”import { number, defineCollection } from '@vexcms/core'
products: defineCollection({ fields: { // Minimal — label inferred from key ("Price") price: number(),
// Required quantity with a minimum of 1 and a database index quantity: number({ required: true, min: { value: 1 }, index: "by_quantity" }),
// Rating capped between 0 and 5 rating: number({ min: { value: 0, error: "Rating cannot be negative" }, max: { value: 5, error: "Rating cannot exceed 5" }, admin: { width: "half" }, }), }})- NumberFieldInput for the full input type
- NumberField for the resolved output type