Example #1
0
        public bool IsValid(string value)
        {
            if (EditorType.HasFlag(EditorType.Required) && String.IsNullOrWhiteSpace(value))
            {
                return(false);
            }

            if (!String.IsNullOrWhiteSpace(value))
            {
                if (this.EditorType.HasFlag(EditorType.EmailAddress) &&
                    !value.CheckRegex(ValidationExtensions.EmailAddressRegex))
                {
                    return(false);
                }

                if (this.EditorType.HasFlag(EditorType.Phone) &&
                    !value.CheckRegex(ValidationExtensions.PhoneNumberRegex))
                {
                    return(false);
                }

                if (!value.CheckRegex(RegexPattern))
                {
                    return(false);
                }
            }

            return(true);
        }