1
0
CompleteNodeJS/notes-app/node_modules/validator/lib/util/assertString.js
Jason Williams 6528d7204a Section 20
2019-08-11 12:15:16 -06:00

28 lines
1.0 KiB
JavaScript

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
exports.default = assertString;
function assertString(input) {
var isString = typeof input === 'string' || input instanceof String;
if (!isString) {
var invalidType = void 0;
if (input === null) {
invalidType = 'null';
} else {
invalidType = typeof input === 'undefined' ? 'undefined' : _typeof(input);
if (invalidType === 'object' && input.constructor && input.constructor.hasOwnProperty('name')) {
invalidType = input.constructor.name;
} else {
invalidType = 'a ' + invalidType;
}
}
throw new TypeError('Expected string but received ' + invalidType + '.');
}
}
module.exports = exports['default'];