B
Berryl Hesh
I want a ConfigurationProperty property to be validated; it should always be
the name of some interface of some sort so it just needs to start with an
"I".
Pattern = @"^I"
TestInput = "IEmployeeRepository"
Iinstantiating a RegexStringValidator as a variable works as expected:
[Test] public void InterfaceValidatorTest() {
var validator = new RegexStringValidator(@"^I");
<----------------succeds without a "*"
validator.Validate("IEmployeeRepository");
}
But as an attribute, it fails unless I add an asterisk ("*") after the
pattern:
[ConfigurationProperty("repositoryInterface", IsKey = true, IsRequired =
true)]
[RegexStringValidator(@"^I*")] public string InterfaceName {
<------------------fails without a "*"
get { return (string) this["repositoryInterface"]; }
set { this["repositoryInterface"] = value; }
}
Why the discrepency?
the name of some interface of some sort so it just needs to start with an
"I".
Pattern = @"^I"
TestInput = "IEmployeeRepository"
Iinstantiating a RegexStringValidator as a variable works as expected:
[Test] public void InterfaceValidatorTest() {
var validator = new RegexStringValidator(@"^I");
<----------------succeds without a "*"
validator.Validate("IEmployeeRepository");
}
But as an attribute, it fails unless I add an asterisk ("*") after the
pattern:
[ConfigurationProperty("repositoryInterface", IsKey = true, IsRequired =
true)]
[RegexStringValidator(@"^I*")] public string InterfaceName {
<------------------fails without a "*"
get { return (string) this["repositoryInterface"]; }
set { this["repositoryInterface"] = value; }
}
Why the discrepency?