UNPKG

@opra/common

Version:
96 lines (95 loc) 4.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EmailType = void 0; const tslib_1 = require("tslib"); const valgen_1 = require("valgen"); const constants_js_1 = require("../../constants.js"); const simple_type_js_1 = require("../simple-type.js"); let EmailType = class EmailType { constructor(attributes) { if (attributes) Object.assign(this, attributes); } [constants_js_1.DECODER](properties) { return valgen_1.vg.isEmail({ ...properties, coerce: true }); } [constants_js_1.ENCODER](properties) { return valgen_1.vg.isEmail({ ...properties, coerce: true }); } }; exports.EmailType = EmailType; tslib_1.__decorate([ simple_type_js_1.SimpleType.Attribute({ description: 'If set to `true`, the validator will also match `Display Name <email-address>', default: false, }), tslib_1.__metadata("design:type", Boolean) ], EmailType.prototype, "allowDisplayName", void 0); tslib_1.__decorate([ simple_type_js_1.SimpleType.Attribute({ description: 'If set to `true`, the validator will reject strings without the format `Display Name <email-address>', default: false, }), tslib_1.__metadata("design:type", Boolean) ], EmailType.prototype, "requireDisplayName", void 0); tslib_1.__decorate([ simple_type_js_1.SimpleType.Attribute({ description: "If set to `false`, the validator will not allow any non-English UTF8 character in email address's local part", default: true, }), tslib_1.__metadata("design:type", Boolean) ], EmailType.prototype, "utf8LocalPart", void 0); tslib_1.__decorate([ simple_type_js_1.SimpleType.Attribute({ description: 'If set to `true`, the validator will not check for the standard max length of an email', default: false, }), tslib_1.__metadata("design:type", Boolean) ], EmailType.prototype, "ignoreMaxLength", void 0); tslib_1.__decorate([ simple_type_js_1.SimpleType.Attribute({ description: 'If set to `true`, the validator will allow IP addresses in the host part', default: false, }), tslib_1.__metadata("design:type", Boolean) ], EmailType.prototype, "allowIpDomain", void 0); tslib_1.__decorate([ simple_type_js_1.SimpleType.Attribute({ description: 'If set to `true`, some additional validation will be enabled, ' + 'e.g. disallowing certain syntactically valid email addresses that are rejected by GMail.', default: false, }), tslib_1.__metadata("design:type", Boolean) ], EmailType.prototype, "domainSpecificValidation", void 0); tslib_1.__decorate([ simple_type_js_1.SimpleType.Attribute({ description: 'If set to an array of strings and the part of the email after the @ symbol ' + ' one of the strings defined in it, the validation fails.', }), tslib_1.__metadata("design:type", Array) ], EmailType.prototype, "hostBlacklist", void 0); tslib_1.__decorate([ simple_type_js_1.SimpleType.Attribute({ description: 'If set to an array of strings and the part of the email after the @ symbol ' + ' matches none of the strings defined in it, the validation fails.', }), tslib_1.__metadata("design:type", Array) ], EmailType.prototype, "hostWhitelist", void 0); tslib_1.__decorate([ simple_type_js_1.SimpleType.Attribute({ description: 'If set to a string, then the validator will reject emails that include ' + ' any of the characters in the string, in the name part.', }), tslib_1.__metadata("design:type", String) ], EmailType.prototype, "blacklistedChars", void 0); exports.EmailType = EmailType = tslib_1.__decorate([ ((0, simple_type_js_1.SimpleType)({ name: 'email', description: 'An email value', nameMappings: { js: 'string', json: 'string', }, }).Example('some.body@example.com')), tslib_1.__metadata("design:paramtypes", [Object]) ], EmailType);