import {Pattern} from "@lion/form-core"; export class IsEmail extends Pattern { /** * Regexes for validating email addresses incl. email in angle-brackets eg. * + "Ralf Becker " * + "Ralf Becker (EGroupware GmbH) " * + "" or "rb@egroupware.org" * + '"Becker, Ralf" ' * + "'Becker, Ralf' " * but NOT: * - "Becker, Ralf " (contains comma outside " or ' enclosed block) * - "Becker < Ralf " (contains < ----------- " ---------------) * * About umlaut or IDN domains: we currently only allow German umlauts in domain part! * We forbid all non-ascii chars in local part, as Horde does not yet support SMTPUTF8 extension (rfc6531) * and we get a "SMTP server does not support internationalized header data" error otherwise. * * Using \042 instead of " to NOT stall minifyer! * * Similar, but not identical, preg is in Etemplate\Widget\Url PHP class! * We can not use "(?@,;:\042\[\]\x80-\xff]+@([a-z0-9ÄÖÜäöüß](|[a-z0-9ÄÖÜäöüß_-]*[a-z0-9ÄÖÜäöüß])\.)+[a-z]{2,}>?$/i); constructor() { super(IsEmail.EMAIL_PREG); } /** * Give a message about this field being required. Could be customised according to MessageData. * @param {MessageData | undefined} data * @returns {Promise} */ static async getMessage(data) { return data.formControl.egw().lang("Invalid email"); } }