UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

22 lines (21 loc) 1.04 kB
import type { ImmutableDictionary } from "../util/dictionary.js"; import type { SchemaOptions } from "./Schema.js"; import { Schema } from "./Schema.js"; /** Allowed options for `DictionarySchema` */ export interface DictionarySchemaOptions<T> extends SchemaOptions { readonly items: Schema<T>; readonly value?: ImmutableDictionary | undefined; readonly min?: number | undefined; readonly max?: number | undefined; } /** Validate a dictionary object (whose props are all the same with string keys). */ export declare class DictionarySchema<T> extends Schema<ImmutableDictionary<T>> { readonly value: ImmutableDictionary<T>; readonly items: Schema<T>; readonly min: number; readonly max: number; constructor({ items, one, many, placeholder, min, max, title, value, ...options }: DictionarySchemaOptions<T>); validate(unsafeValue?: unknown): ImmutableDictionary<T>; } /** Valid dictionary object with specifed items. */ export declare const DICTIONARY: <T>(items: Schema<T>) => DictionarySchema<T>;