Ejemplo n.º 1
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (!Email.IsNullOrEmpty())
            {
                string address = null;
                try
                {
                    address = new MailAddress(Email).Address;
                }
                catch
                {
                    // ignored
                }

                if (address.IsNullOrEmpty())
                {
                    yield return(new ValidationResult("电子邮箱不符合规范,请输入正确的邮箱", new[] { "Email" }));
                }
            }
        }