UNPKG

@opra/common

Version:
102 lines (101 loc) 3.7 kB
import { __decorate, __metadata } from "tslib"; import { vg } from 'valgen'; import { DECODER, ENCODER } from '../../constants.js'; import { SimpleType } from '../simple-type.js'; let EmailType = class EmailType { constructor(attributes) { if (attributes) Object.assign(this, attributes); } allowDisplayName; requireDisplayName; utf8LocalPart; ignoreMaxLength; allowIpDomain; domainSpecificValidation; hostBlacklist; hostWhitelist; blacklistedChars; [DECODER](properties) { return vg.isEmail({ ...properties, coerce: true }); } [ENCODER](properties) { return vg.isEmail({ ...properties, coerce: true }); } }; __decorate([ SimpleType.Attribute({ description: 'If set to `true`, the validator will also match `Display Name <email-address>', default: false, }), __metadata("design:type", Boolean) ], EmailType.prototype, "allowDisplayName", void 0); __decorate([ SimpleType.Attribute({ description: 'If set to `true`, the validator will reject strings without the format `Display Name <email-address>', default: false, }), __metadata("design:type", Boolean) ], EmailType.prototype, "requireDisplayName", void 0); __decorate([ 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, }), __metadata("design:type", Boolean) ], EmailType.prototype, "utf8LocalPart", void 0); __decorate([ SimpleType.Attribute({ description: 'If set to `true`, the validator will not check for the standard max length of an email', default: false, }), __metadata("design:type", Boolean) ], EmailType.prototype, "ignoreMaxLength", void 0); __decorate([ SimpleType.Attribute({ description: 'If set to `true`, the validator will allow IP addresses in the host part', default: false, }), __metadata("design:type", Boolean) ], EmailType.prototype, "allowIpDomain", void 0); __decorate([ 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, }), __metadata("design:type", Boolean) ], EmailType.prototype, "domainSpecificValidation", void 0); __decorate([ 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.', }), __metadata("design:type", Array) ], EmailType.prototype, "hostBlacklist", void 0); __decorate([ 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.', }), __metadata("design:type", Array) ], EmailType.prototype, "hostWhitelist", void 0); __decorate([ 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.', }), __metadata("design:type", String) ], EmailType.prototype, "blacklistedChars", void 0); EmailType = __decorate([ (SimpleType({ name: 'email', description: 'An email value', nameMappings: { js: 'string', json: 'string', }, }).Example('some.body@example.com')), __metadata("design:paramtypes", [Object]) ], EmailType); export { EmailType };