nowjs-core
Version:
NowCanDo Javascript Core [nowjs-core] is a library written by TypeScript code maintains under Apache 2.0 licence
20 lines (19 loc) • 901 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("../index");
const index_2 = require("./index");
exports.VALIDATOR_FUNCTION_METADATA_KEY = Symbol('validation:validator:isFunction');
function isFunction(errorMessage) {
return (target, propertyKey, descriptor) => {
const original = descriptor.value;
Reflect.defineMetadata(exports.VALIDATOR_FUNCTION_METADATA_KEY, null, target, propertyKey);
Reflect.defineMetadata(index_1.VALIDATOR_METADATA_KEY, new FunctionValidator(errorMessage), target, propertyKey);
};
}
exports.isFunction = isFunction;
class FunctionValidator extends index_2.ValueTypeValidatorBase {
constructor(errorMessage = 'The value of ${DisplayName} must have valu type: ${ValueType} .') {
super('Function', 'function', errorMessage);
}
}
exports.FunctionValidator = FunctionValidator;