lazy-widgets
Version:
Typescript retained mode GUI for the HTML canvas API
29 lines • 952 B
JavaScript
/**
* A validator function which checks whether an input value is a
* {@link KeyContext}. Doesn't stop the validator chain.
*
* @category XML
*/
export function validateKeyContext(value) {
if (typeof value !== 'object') {
throw new Error('Invalid KeyContext; not an object');
}
if (value === null) {
throw new Error('Invalid KeyContext; null');
}
const kc = value;
if (typeof kc.callback !== 'function') {
throw new Error('Invalid KeyContext; callback is not a function');
}
if (typeof kc.shift !== 'boolean') {
throw new Error('Invalid KeyContext; shift is not a boolean');
}
if (typeof kc.ctrl !== 'boolean') {
throw new Error('Invalid KeyContext; ctrl is not a boolean');
}
if (typeof kc.alt !== 'boolean') {
throw new Error('Invalid KeyContext; alt is not a boolean');
}
return [kc, false];
}
//# sourceMappingURL=validateKeyContext.js.map