@jc-lab/jose
Version:
JSON Web Almost Everything - JWA, JWS, JWE, JWK, JWT, JWKS for Node.js with minimal dependencies
13 lines (10 loc) • 400 B
JavaScript
const isNotString = val => typeof val !== 'string' || val.length === 0
module.exports.isNotString = isNotString
module.exports.isString = function isString (Err, value, label, required = false) {
if (required && value === undefined) {
throw new Err(`${label} is missing`)
}
if (value !== undefined && isNotString(value)) {
throw new Err(`${label} must be a string`)
}
}