예제 #1
0
        /// <summary>Initializes a new instance of the <see cref="EmailValidator"/> class.</summary>
        /// <param name="name">The name for the validator.</param>
        /// <param name="messageTemplate">The template to use when logging validation results, or null we the default message template is to be used.</param>
        /// <param name="tag">The tag to set when logging validation results, or null.</param>
        /// <param name="negated">Indicates if the validation logic represented by the validator should be negated.</param>
        public EmailValidator(string name, string messageTemplate, string tag, bool negated)
            : base(messageTemplate, tag, negated)
        {
            this.Name     = name;
            this.Category = EmailCategory.Basic;

            if (ConfiguredValues != null && ConfiguredValues.Count > 0)
            {
                ConfiguredValuesContainer container = null;
                if (ConfiguredValues.ContainsKey(this.Name))
                {
                    container = ConfiguredValues[this.Name];
                }
                else if (ConfiguredValues.ContainsKey(DefaultName))
                {
                    container = ConfiguredValues[DefaultName];
                }

                if (container != null)
                {
                    this.AllowComments         = container.AllowComments;
                    this.AllowIPAddresses      = container.AllowIPAddresses;
                    this.RequireTopLevelDomain = container.RequireTopLevelDomain;
                    this.IncludeDomains        = container.IncludeDomains;
                    this.ExcludeDomains        = container.ExcludeDomains;
                }
            }
        }
예제 #2
0
        /// <summary>Initializes a new instance of the <see cref="DutchPhoneNumberValidator"/> class.</summary>
        /// <param name="name">The name for the validator.</param>
        /// <param name="messageTemplate">The template to use when logging validation results, or null we the default message template is to be used.</param>
        /// <param name="tag">The tag to set when logging validation results, or null.</param>
        /// <param name="negated">Indicates if the validation logic represented by the validator should be negated.</param>
        public DutchPhoneNumberValidator(string name, string messageTemplate, string tag, bool negated)
            : base(messageTemplate, tag, negated)
        {
            this.Name       = name;
            this.Categories = PhoneNumberCategories.Default;
            this.AllowCountryCallingCode = true;

            if (ConfiguredValues != null && ConfiguredValues.Count > 0)
            {
                ConfiguredValuesContainer container = null;
                if (ConfiguredValues.ContainsKey(this.Name))
                {
                    container = ConfiguredValues[this.Name];
                }
                else if (ConfiguredValues.ContainsKey(DefaultName))
                {
                    container = ConfiguredValues[DefaultName];
                }

                if (container != null)
                {
                    this.AllowCountryCallingCode = container.AllowCountryCallingCode;
                    this.AllowCarrierPreselect   = container.AllowCarrierPreselect;
                    if (container.AreaCodesOverridden)
                    {
                        this.IncludeAreaCodes = container.AreaCodes;
                    }
                }
            }
        }