I downloaded the Validation Application Block and I am attempting to use the already written USStateValidator that is provided with the ValidationAspNetQuickStart.
I added the following to the ValidationQuickStart.BusinessEntities.dll.config file under "Address", "RuleSetB".
<property name="State">
<validator messageTemplate="Site State: Must be a valid two-digit US state designation." messageTemplateResourceName=""
messageTemplateResourceType="" tag="" type="ValidationQuickStart.CustomValidators.USStateValidator, ValidationQuickStart.CustomValidators, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
name="USStateValidator" />
</property>
When I attempt to validate the form in the test application using "RulesetB", it gives me the followin error: "Constructor on type "ValidationQuickStart.CustomValidators.USStateValidator" not found."
Here is the code for the validator as provided by Microsoft (I have made no changes to it):
namespace ValidationQuickStart.CustomValidators
{
[ConfigurationElementType(typeof(CustomValidatorData))]
public class USStateValidator : DomainValidator<string>
{
private static List<string> stateCodes = new List<string>(new string[] {
"AL", "AK", "AS", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FM", "FL",
"GA", "GU", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MH",
"MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM",
"NY", "NC", "ND", "MP", "OH", "OK", "OR", "PW", "PA", "PR", "RI", "SC",
"SD", "TN", "TX", "UT", "VT", "VI", "VA", "WA", "WV", "WI", "WY"});
public USStateValidator()
: base(stateCodes)
{
}
protected override string DefaultNonNegatedMessageTemplate
{
get { return "The supplied code does not represent a valid US State"; }
}
}
}
The USStateValidator appears to work normally when using "RulesetA" which uses only attributes on the BusinessEntity class.
Here is the example from the business entity class that works just fine:
[USStateValidator(Ruleset = "RuleSetA")]
public string State
{
get { return state; }
set { state = value; }
}
Does anyone know what is wrong with this? I need to get this validator working using the xml file instead of declaring on the actual class itself.