nowjs-core
Version:
NowCanDo Javascript Core [nowjs-core] is a library written by TypeScript code maintains under Apache 2.0 licence
21 lines (20 loc) • 957 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("../index");
const index_2 = require("./index");
exports.VALIDATOR_NEGATIVE_METADATA_KEY = Symbol('validation:validator:negative');
function negative(errorMessage) {
return (target, propertyKey, descriptor) => {
const original = descriptor.value;
Reflect.defineMetadata(exports.VALIDATOR_NEGATIVE_METADATA_KEY, null, target, propertyKey);
Reflect.defineMetadata(index_1.VALIDATOR_METADATA_KEY, new NegativeValidator(errorMessage), target, propertyKey);
};
}
exports.negative = negative;
exports.PATTERN_NEGATIVE = /^\-\d+\.?\d*$/gi;
class NegativeValidator extends index_2.PatternValidatorBase {
constructor(errorMessage = 'The value of ${DisplayName} must have negative pattern : ${Pattern} .') {
super('Negative', exports.PATTERN_NEGATIVE, errorMessage);
}
}
exports.NegativeValidator = NegativeValidator;