DictionarySchemaclass

new DictionarySchema<T>({
		items,
		one = items.one,
		many = items.many,
		placeholder = `No ${many}`,
		min = 0,
		max = Number.POSITIVE_INFINITY,
		title = "Items",
		value = {},
		...options
	}: DictionarySchemaOptions<T>)
ParamType
optionsDictionarySchemaOptions<T>
Options for DictionarySchema. required
    .itemsSchema<T>
Schema every entry value in the dictionary must conform to. required readonly
    .valueImmutableDictionary
Default dictionary used when the input is undefined. readonly
    .minnumber
Minimum number of entries. Defaults to 0 readonly
    .maxnumber
Maximum number of entries. Defaults to Number.POSITIVE_INFINITY readonly
Return
DictionarySchema<T>
Schema that validates a dictionary object whose entries all share the same value schema and have string keys.
PropertyType
.itemsSchema<T>
Schema is an object instance with a validate() method that converts unknown input into a known, valid type T. required readonly
.minnumber
required readonly
.maxnumber
required readonly

Schema that validates a dictionary object whose entries all share the same value schema and have string keys.

  • Every entry value is validated by the items schema.
  • Entry count is checked against min and max.

Examples

const schema = new DictionarySchema({ items: NUMBER });
 schema.validate({ a: 1, b: 2 }); // { a: 1, b: 2 }