I am using JQuery as my JavaScript library and have a need for a
custom validator. I have defined an validation attibute
(ValidateValidGuidAttribute) and a validation generator
(ValidGuidValidator).
Now my question is: where is the "right" extension point to configure
the Browser Validation Generator (in my case JQueryValidator) that I
have a custom validator?
I have a working solution but I feel a strong code smell!
What I have done is:
I have sub-classed JQueryValidator and JQueryConfiguration
(JqueryValidatorEx and JQueryConfigurationEx)
and in the Validator I have down-cast (SMELL!!!) the generator, i.e.
public override void
ApplyBrowserValidation(BrowserValidationConfiguration config,
InputElementType inputType, IBrowserValidationGenerator generator,
IDictionary attributes, string target)
{
base.ApplyBrowserValidation(config, inputType, generator,
attributes, target);
var jqGenerator = generator as
JQueryValidatorEx.JQueryValidationGenerator;
if (jqGenerator == null) throw new
InvalidOperationException("Only JQuery validator plug-in is
supported!");
jqGenerator.SetAsValidGuid(target,
this.BuildErrorMessage());
}
is there a "proper" way of doing it?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---