Skip to content

NumberFieldInput

Defined in: packages/core/src/fields/number/types.ts:49

Configuration input for a number() field.

Number fields store numeric values — prices, quantities, ratings, ages, counts, etc. All properties are optional; unset properties fall back to the defaults listed below.

Defaults applied by number():

{
type: "number",
label: "", // inferred from the field key by defineCollection
required: false, // field is optional by default
admin: {
hidden: false, // visible in the admin form
readOnly: false, // editable by default
position: "main", // placed in the main content column, not the sidebar
width: "full", // spans the full form width, not half
cellAlignment: "left", // value aligned left in the data table column
}
}
// Minimal — label is inferred from the 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 with custom error messages
rating: number({
min: { value: 0, error: "Rating cannot be negative" },
max: { value: 5, error: "Rating cannot exceed 5" },
admin: { width: "half" },
})
// Pre-filled default for a score field
score: number({ defaultValue: 100 })
  • NumberField for the resolved type after defaults are applied
  • number for the config function that applies defaults
  • BaseFieldInput for shared properties (label, description, required, admin, index, searchIndex)

TFieldMeta extends object = { }

optional admin?: FieldAdminConfigInput

Defined in: packages/core/src/fields/baseTypes.ts:209

Admin UI configuration for this field.

BaseFieldInput.admin


optional defaultValue?: number

Defined in: packages/core/src/fields/number/types.ts:56

Pre-filled value shown in the admin form when creating a new document. Does not affect database values — only the form’s initial state.

BaseFieldInput.defaultValue


optional description?: string

Defined in: packages/core/src/fields/baseTypes.ts:194

Semantic description of the field. Used in three places:

  1. Helper text rendered below the field input in the admin form UI.
  2. As the Zod .meta({ description }) value for form validation.
  3. As the JSDoc comment on the generated document interface property.

To write a separate JSDoc comment, use interfaceDescription in addition.

BaseFieldInput.description


optional index?: string

Defined in: packages/core/src/fields/baseTypes.ts:220

Create a database index on this field. The string value becomes the index name in Convex.

slug: { type: "text", index: "by_slug", required: true }
// Generates: .index("by_slug", ["slug"])

BaseFieldInput.index


optional interfaceDescription?: string

Defined in: packages/core/src/fields/baseTypes.ts:196

The JSDoc comment on the generated document interface property

BaseFieldInput.interfaceDescription


optional label?: string

Defined in: packages/core/src/fields/baseTypes.ts:185

Display label for the field in the admin form.

BaseFieldInput.label


optional max?: object

Defined in: packages/core/src/fields/number/types.ts:65

Maximum allowed numeric value config.

optional error?: string

Error message shown when the value exceeds the maximum.

value: number

Maximum allowed numeric value.


optional meta?: TFieldMeta

Defined in: packages/core/src/fields/baseTypes.ts:221

BaseFieldInput.meta


optional min?: object

Defined in: packages/core/src/fields/number/types.ts:58

Minimum allowed numeric value config.

optional error?: string

Error message shown when the value is below the minimum.

value: number

Minimum allowed numeric value.


optional required?: boolean

Defined in: packages/core/src/fields/baseTypes.ts:202

Whether this field is required.

Default: false

BaseFieldInput.required