shelving
Version:
Toolkit for using data in JavaScript.
23 lines (22 loc) • 1.05 kB
TypeScript
import type { PossibleDate } from "../util/date.js";
import type { Optional } from "../util/optional.js";
import type { SchemaOptions } from "./Schema.js";
import { Schema } from "./Schema.js";
/** Allowed options for `DateSchema` */
export interface DateSchemaOptions extends SchemaOptions {
readonly value?: PossibleDate | undefined;
readonly min?: Optional<PossibleDate> | undefined;
readonly max?: Optional<PossibleDate> | undefined;
}
/** Define a valid date in YMD format, e.g. `2005-09-12` */
export declare class DateSchema extends Schema<string> {
readonly value: PossibleDate;
readonly min: Date | undefined;
readonly max: Date | undefined;
constructor({ min, max, title, value, ...options }: DateSchemaOptions);
validate(value?: unknown): string;
}
/** Valid date, e.g. `2005-09-12` (required because falsy values are invalid). */
export declare const DATE: DateSchema;
/** Valid date, e.g. `2005-09-12`, or `null` */
export declare const OPTIONAL_DATE: import("./OptionalSchema.js").OptionalSchema<string>;