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) • 1.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("../index");
const index_2 = require("./index");
exports.VALIDATOR_EMAIL_METADATA_KEY = Symbol('validation:validator:isEmail');
function isEmail(errorMessage) {
return (target, propertyKey, descriptor) => {
const original = descriptor.value;
Reflect.defineMetadata(exports.VALIDATOR_EMAIL_METADATA_KEY, null, target, propertyKey);
Reflect.defineMetadata(index_1.VALIDATOR_METADATA_KEY, new EmailValidator(errorMessage), target, propertyKey);
};
}
exports.isEmail = isEmail;
exports.PATTERN_EMAIL_UNIVERSAL = /^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$/gi;
class EmailValidator extends index_2.PatternValidatorBase {
constructor(errorMessage = 'The value of ${DisplayName} must have email pattern : ${Pattern} .') {
super('Email', exports.PATTERN_EMAIL_UNIVERSAL, errorMessage);
}
}
exports.EmailValidator = EmailValidator;