shelving
Version:
Toolkit for using data in JavaScript.
39 lines (38 loc) • 2 kB
TypeScript
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;
}
/** Schema that defines a valid number. */
export declare class NumberSchema extends Schema<number> {
readonly value: number;
readonly min: number;
readonly max: number;
readonly step: number | undefined;
constructor({ min, max, step, title, value, ...options }: NumberSchemaOptions);
validate(unsafeValue?: unknown): number;
}
/** Valid number, e.g. `2048.12345` or `0` zero. */
export declare const NUMBER: NumberSchema;
/** Valid optional number, e.g. `2048.12345` or `0` zero, or `null` */
export declare const OPTIONAL_NUMBER: import("./OptionalSchema.js").OptionalSchema<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 OPTIONAL_INTEGER: import("./OptionalSchema.js").OptionalSchema<number>;
/** Valid Unix timestamp (including milliseconds). */
export declare const TIMESTAMP: NumberSchema;
/** Valid Unix timestamp (including milliseconds). */
export declare const OPTIONAL_TIMESTAMP: import("./OptionalSchema.js").OptionalSchema<number>;