I want a ConfigurationPr operty 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 = "IEmployeeRepos itory"
Iinstantiating a RegexStringVali dator as a variable works as expected:
[Test] public void InterfaceValida torTest() {
var validator = new RegexStringVali dator(@"^I");
<----------------succeds without a "*"
validator.Valid ate("IEmployeeR epository");
}
But as an attribute, it fails unless I add an asterisk ("*") after the
pattern:
[ConfigurationPr operty("reposit oryInterface", IsKey = true, IsRequired =
true)]
[RegexStringVali dator(@"^I*")] public string InterfaceName {
<------------------fails without a "*"
get { return (string) this["repositoryInte rface"]; }
set { this["repositoryInte rface"] = value; }
}
Why the discrepency?
the name of some interface of some sort so it just needs to start with an
"I".
Pattern = @"^I"
TestInput = "IEmployeeRepos itory"
Iinstantiating a RegexStringVali dator as a variable works as expected:
[Test] public void InterfaceValida torTest() {
var validator = new RegexStringVali dator(@"^I");
<----------------succeds without a "*"
validator.Valid ate("IEmployeeR epository");
}
But as an attribute, it fails unless I add an asterisk ("*") after the
pattern:
[ConfigurationPr operty("reposit oryInterface", IsKey = true, IsRequired =
true)]
[RegexStringVali dator(@"^I*")] public string InterfaceName {
<------------------fails without a "*"
get { return (string) this["repositoryInte rface"]; }
set { this["repositoryInte rface"] = value; }
}
Why the discrepency?
Comment