shelving
Version:
Toolkit for using data in JavaScript.
30 lines (29 loc) • 1.46 kB
TypeScript
import type { Optional } from "../util/optional.js";
import type { PossibleTime } from "../util/time.js";
import { Time } from "../util/time.js";
import type { SchemaOptions } from "./Schema.js";
import { Schema } from "./Schema.js";
/** Allowed options for `TimeSchama` */
export interface TimeSchemaOptions extends SchemaOptions {
readonly value?: PossibleTime | undefined;
readonly min?: Optional<PossibleTime> | undefined;
readonly max?: Optional<PossibleTime> | undefined;
readonly step?: number | undefined;
}
/** Define a valid time in 24h hh:mm:ss.fff format, e.g. `23:59` or `24:00 */
export declare class TimeSchema extends Schema<string> {
readonly value: PossibleTime;
readonly min: Time | undefined;
readonly max: Time | undefined;
/**
* Rounding step (in milliseconds, because that's the base unit for time), e.g. `60000` will round to the nearest second.
* - Note: `<input type="time">` elements expect `step=""` to be in _seconds_ so you need to multiply this by `1000`
*/
readonly step: number | undefined;
constructor({ min, max, step, title, value, ...options }: TimeSchemaOptions);
validate(unsafeValue?: unknown): string;
}
/** Valid time, e.g. `2005-09-12` (required because falsy values are invalid). */
export declare const TIME: TimeSchema;
/** Valid time, e.g. `2005-09-12`, or `null` */
export declare const OPTIONAL_TIME: import("./OptionalSchema.js").OptionalSchema<string>;