UNPKG

lazy-widgets

Version:

Typescript retained mode GUI for the HTML canvas API

27 lines 963 B
import { Widget } from '../widgets/Widget.js'; /** * A validator function which checks whether an input value is a * {@link LayerInit}. Doesn't stop the validator chain. * * @category XML */ export function validateLayerInit(value) { if (typeof value !== 'object') { throw new Error('Invalid LayerInit; not an object'); } if (value === null) { throw new Error('Invalid LayerInit; null'); } const li = value; if (!(li.child instanceof Widget)) { throw new Error('Invalid LayerInit; child is not a Widget'); } if (li.name !== undefined && typeof li.name !== 'string') { throw new Error('Invalid LayerInit; name was provided but is not a string'); } if (li.canExpand !== undefined && typeof li.canExpand !== 'boolean') { throw new Error('Invalid LayerInit; canExpand was provided but is not a boolean'); } return [li, false]; } //# sourceMappingURL=validateLayerInit.js.map