shelving
Version:
Toolkit for using data in JavaScript.
18 lines (17 loc) • 946 B
TypeScript
import { type ImmutableArray } from "../util/array.js";
import { type Entity } from "../util/entity.js";
import { StringSchema, type StringSchemaOptions } from "./StringSchema.js";
/** Allowed options for `EntitySchema` with specific types */
export interface EntitySchemaOptions<T extends string> extends StringSchemaOptions {
readonly types?: ImmutableArray<T> | undefined;
}
/** Validate a file name matching one or more extensions. */
export declare class EntitySchema<T extends string> extends StringSchema {
readonly types: ImmutableArray<T> | undefined;
constructor({ types, title, ...options }: EntitySchemaOptions<T>);
validate(unsafeValue?: unknown): Entity<T>;
}
/** Valid file, e.g. `challenge:a1b2c3` */
export declare const ENTITY: EntitySchema<string>;
/** Valid optional file, e.g. `file.txt`, or `null` */
export declare const OPTIONAL_ENTITY: import("./OptionalSchema.js").OptionalSchema<`${string}:${string}`>;