UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

43 lines (42 loc) 2.24 kB
import { formatNumber } from "../util/format.js"; import type { SchemaOptions } from "./Schema.js"; import { Schema } from "./Schema.js"; /** Allowed options for `NumberSchema` */ export interface NumberSchemaOptions extends SchemaOptions { readonly value?: number | undefined; readonly min?: number | undefined; readonly max?: number | undefined; readonly step?: number | undefined; /** Format the number for display in downstream UIs. */ readonly format?: typeof formatNumber | undefined; } /** Schema that defines a valid number. */ export declare class NumberSchema extends Schema<number> { readonly value: number | undefined; readonly min: number; readonly max: number; readonly step: number | undefined; constructor({ one, title, min, max, step, format, value, ...options }: NumberSchemaOptions); validate(value?: unknown): number; format(value: number): string; } /** Valid number, e.g. `2048.12345` or `0` zero and a default value of zero. */ export declare const NUMBER: NumberSchema; /** Valid optional number, e.g. `2048.12345` or `0` zero, or `null` */ export declare const NULLABLE_NUMBER: import("./NullableSchema.js").NullableSchema<number>; /** Valid integer number, e.g. `2048` or `0` zero. */ export declare const INTEGER: NumberSchema; /** Valid positive integer number, e.g. `1,2,3` (not including zero). */ export declare const POSITIVE_INTEGER: NumberSchema; /** Valid non-negative integer number, e.g. `0,1,2,3` (including zero). */ export declare const NON_NEGATIVE_INTEGER: NumberSchema; /** Valid negative integer number, e.g. `-1,-2,-3` (not including zero). */ export declare const NEGATIVE_INTEGER: NumberSchema; /** Valid non-positive integer number, e.g. `0,-1,-2,-3` (including zero). */ export declare const NON_POSITIVE_INTEGER: NumberSchema; /** Valid optional integer number, e.g. `2048` or `0` zero, or `null` */ export declare const NULLABLE_INTEGER: import("./NullableSchema.js").NullableSchema<number>; /** Valid Unix timestamp (including milliseconds). */ export declare const TIMESTAMP: NumberSchema; /** Valid Unix timestamp (including milliseconds). */ export declare const NULLABLE_TIMESTAMP: import("./NullableSchema.js").NullableSchema<number>;