in apps/mountebank-mock/mountebank-source/src/models/behaviorsValidator.js [87:112]
function addTypeErrors (fieldSpec, path, field, config, addErrorFn) {
/* eslint complexity: 0 */
const fieldType = typeof field,
allowedTypes = Object.keys(fieldSpec._allowedTypes), // eslint-disable-line no-underscore-dangle
typeSpec = fieldSpec._allowedTypes[fieldType]; // eslint-disable-line no-underscore-dangle
if (!helpers.defined(typeSpec)) {
addErrorFn(path, typeErrorMessageFor(allowedTypes, fieldSpec._additionalContext)); // eslint-disable-line no-underscore-dangle
}
else {
if (typeSpec.singleKeyOnly && !hasExactlyOneKey(field)) {
addErrorFn(path, 'must have exactly one key');
}
else if (typeSpec.enum && !matchesEnum(field, typeSpec.enum)) {
addErrorFn(path, `must be one of [${typeSpec.enum.join(', ')}]`);
}
else if (typeSpec.nonNegativeInteger && field < 0) {
addErrorFn(path, 'must be an integer greater than or equal to 0');
}
else if (typeSpec.positiveInteger && field <= 0) {
addErrorFn(path, 'must be an integer greater than 0');
}
addErrorsFor(config, path, fieldSpec, addErrorFn);
}
}