in src/ccf/ccf-provider-common/constitution/actions.js [41:60]
function checkType(value, type, field) {
const optional = type.endsWith("?");
if (optional) {
if (value === null || value === undefined) {
return;
}
type = type.slice(0, -1);
}
if (type === "array") {
if (!Array.isArray(value)) {
throw new Error(`${field} must be an array`);
}
} else if (type === "integer") {
if (!Number.isInteger(value)) {
throw new Error(`${field} must be an integer`);
}
} else if (typeof value !== type) {
throw new Error(`${field} must be of type ${type} but is ${typeof value}`);
}
}