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) • 900 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("../index");
const index_2 = require("./index");
exports.VALIDATOR_ARRAY_METADATA_KEY = Symbol('validation:validator:isArray');
function isArray(valueType, errorMessage) {
return (target, propertyKey, descriptor) => {
const original = descriptor.value;
Reflect.defineMetadata(exports.VALIDATOR_ARRAY_METADATA_KEY, null, target, propertyKey);
Reflect.defineMetadata(index_1.VALIDATOR_METADATA_KEY, new ArrayValidator(valueType, errorMessage), target, propertyKey);
};
}
exports.isArray = isArray;
class ArrayValidator extends index_2.ValueTypeValidatorBase {
constructor(valueType, errorMessage = 'The value of ${DisplayName} must have valu type: ${ValueType} .') {
super('Array', valueType, errorMessage);
}
}
exports.ArrayValidator = ArrayValidator;