UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

22 lines (21 loc) 848 B
/** * Schema is an object instance with a `validate()` method. * - Type `T` represents the type of value `validate()` returns. * - `validate()` returns `Invalid` if value was not valid. */ export class Schema { /** Title of the schema, e.g. for using as the title of a corresponding field. */ title; /** Description of the schema, e.g. for using as a description in a corresponding field. */ description; /** Placeholder of the schema, e.g. for using as a placeholder in a corresponding field. */ placeholder; /** Default value for the schema if `validate()` is called with an `undefined` value. */ value; constructor({ title, description, placeholder, value }) { this.title = title; this.description = description; this.placeholder = placeholder; this.value = value; } }