/// <summary> /// Initializes a new instance of the <see cref="RegularExpressionValidatorAttribute"/> class. /// </summary> /// <param name="customRegularExpressionPattern">The custom regular expression pattern.</param> /// <param name="requiredEntry">The required entry.</param> public RegularExpressionValidatorAttribute(String customRegularExpressionPattern, RequiredEntry requiredEntry) { this.RegularExpressionPatternType = RegularExpressionPatternType.Custom; this.RequiredEntry = requiredEntry; if (!(StringValidationRules.IsRegularExpressionPatternValid(customRegularExpressionPattern))) { throw new ArgumentOutOfRangeException("customRegularExpressionPattern", Resources.RegularExpressionValidatorAttribute_RegularExpressionValidatorAttribute_Programmer_did_not_supply_a_valid_CustomRegularExpressionPattern); } this.CustomRegularExpressionPattern = customRegularExpressionPattern; }
/// <summary> /// Initializes a new instance of the <see cref="RegularExpressionRuleDescriptor"/> class. /// </summary> /// <param name="customRegularExpressionPattern">The custom regular expression pattern.</param> /// <param name="requiredEntry">The required entry.</param> /// <param name="customMessage">The custom message.</param> /// <param name="propertyFriendlyName">Name of the property friendly.</param> /// <param name="propertyName">Name of the property.</param> /// <param name="ruleSet">The rule set.</param> /// <param name="overrideMessage">The override message.</param> public RegularExpressionRuleDescriptor(String customRegularExpressionPattern, RequiredEntry requiredEntry, String customMessage, String propertyFriendlyName, String propertyName, String ruleSet, String overrideMessage) : base(customMessage, propertyFriendlyName, propertyName, ruleSet, overrideMessage) { this.RegularExpressionPatternType = RegularExpressionPatternType.Custom; this.RequiredEntry = requiredEntry; if (!(StringValidationRules.IsRegularExpressionPatternValid(customRegularExpressionPattern))) { throw new InvalidOperationException(Resources.RegularExpressionRuleDescriptor_CustomRegularExpressionPattern_value_is_not_a_valid_regular_expression_); } _customRegularExpressionPattern = customRegularExpressionPattern; }
/// <summary> /// Initializes a new instance of the <see cref="RegularExpressionRuleDescriptor"/> class. /// </summary> /// <param name="e">The e.</param> /// <param name="propertyName">Name of the property.</param> public RegularExpressionRuleDescriptor(RegularExpressionValidatorAttribute e, String propertyName) : base(propertyName, e.PropertyFriendlyName, e.RuleSet, e.CustomMessage, e.OverrideMessage) { this.RegularExpressionPatternType = e.RegularExpressionPatternType; if (e.RegularExpressionPatternType == RegularExpressionPatternType.Custom) { if (!(StringValidationRules.IsRegularExpressionPatternValid(e.CustomRegularExpressionPattern))) { throw new InvalidOperationException(Resources.RegularExpressionRuleDescriptor_CustomRegularExpressionPattern_value_is_not_a_valid_regular_expression_); } _customRegularExpressionPattern = e.CustomRegularExpressionPattern; } this.RequiredEntry = e.RequiredEntry; }