Notes/src/etapi/validators.js

30 lines
510 B
JavaScript
Raw Normal View History

2022-01-07 19:33:59 +01:00
function isString(obj) {
if (typeof obj !== 'string') {
return `'${obj}' is not a string`;
}
}
function isStringOrNull(obj) {
if (obj) {
return isString(obj);
}
}
function isBoolean(obj) {
if (typeof obj !== 'boolean') {
return `'${obj}' is not a boolean`;
}
}
function isInteger(obj) {
if (!Number.isInteger(obj)) {
return `'${obj}' is not an integer`;
}
}
module.exports = {
isString,
isStringOrNull,
isBoolean,
isInteger
};