ChatiumFor developersPlaygroundPricing
Sign in

Heap.Number and Heap.Integer

Declares a field of type number. Heap.Integer is similar to Heap.Number, but additionally validates the value for integer-ness.

Usage / Signature

import { Heap } from '@app/heap'
Heap.Number(options)
Heap.Integer(options)

Arguments

  • <b id="options">options</b>: {default, minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf}
    An object with additional optional parameters for the field.

    • <b id="default">default</b>: number
      The default value for this field. For more information on how default values work, see Guide / Heap / Default Values.
    • <b id="minimum">minimum</b>: number
      Validation for the minimum value. "Greater than or equal to" rule.
    • <b id="maximum">maximum</b>: number
      Validation for the maximum value. "Less than or equal to" rule.
    • <b id="exclusiveMinimum">exclusiveMinimum</b>: number
      "Strictly greater than" rule.
    • <b id="exclusiveMaximum">exclusiveMaximum</b>: number
      "Strictly less than" rule.
    • <b id="multipleOf">multipleOf</b>: number
      Validation for multiples of a specified number.

Return Value

JSON schema for the number field.

Examples

Any number
const reports = Heap.Table('reports', {
  relativeChange: Heap.Number(),
})
Any natural number
const counters = Heap.Table('counters', {
  count: Heap.Integer({ minimum: 1 }),
})
An integer multiple of 100 less than 1000
const bets = Heap.Table('bets', {
  amount: Heap.Number({ multipleOf: 100, exclusiveMaximum: 1000 }),
})