altheia-async-data-validator
Version:
A very simple, fast and customizable async data validator
41 lines (40 loc) • 885 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypeFunc = exports.messages = void 0;
const base_1 = require("./base");
exports.messages = {
'function.typeof': (name) => `${name} must be a valid function`,
};
/**
* Function class
*/
class TypeFunc extends base_1.TypeBase {
/**
* Constructor
*/
constructor() {
super();
this.name = 'function';
this.typeof();
}
_cast() {
throw new Error('not available for this validator');
}
/**
* Test to validate the type of the value
*
* @return {this}
*/
typeof() {
this.test('typeof', (str) => {
return typeof str === 'function';
});
return this;
}
}
exports.TypeFunc = TypeFunc;
const def = {
Class: TypeFunc,
messages: exports.messages,
};
exports.default = def;