jose/lib/jwt/shared_validations.js
2019-02-27 22:38:30 +01:00

8 lines
299 B
JavaScript

const isNotString = val => typeof val !== 'string' || val.length === 0
module.exports.isNotString = isNotString
module.exports.isStringOptional = function isStringOptional (Err, value, label) {
if (value !== undefined && isNotString(value)) {
throw new Err(`${label} must be a string`)
}
}