Client-side validation not getting rules from JsonFormatter

Apr 29, 2009 at 4:47 AM

I'm having some trouble getting the client-side validation to work in xVal. The documentation I'm looking at is from 0.5, but I couldn't find anything more recent. I have the following DTO and view. Server-side validation is working just fine, but the client side validation is not cooperating. Am I missing something completely obvious?

The output of the helper method is: <script type="text/javascript">xVal.AttachValidator(null, {"Fields":[]})</script>  (It doesn't seem the Json Formatter is doing its thing.)


class LoginDetailsSubmitted{
ValidateNonEmpty][ValidateEmail]public string EmailAddress { get; set; }
ValidateNonEmpty]public string Password { get; set; }}

<% Html.BeginForm(

"Login", "Registration"); %><div>
<label>Email Address</label>
<%= Html.TextBox("EmailAddress") %>
= Html.ValidationMessage("EmailAddress")%>
<%= Html.Password("Password")%>
= Html.ValidationMessage("Password")%>
<input type="submit" />
<% Html.EndForm(); %>
= Html.ClientSideValidation<LoginDetailsSubmitted>()%>


Apr 29, 2009 at 4:57 AM
I just found the notes on 0.8 and saw the bit about adding an ActiveRuleProvider. That fixed everything.

Thanks for the work on the xVal. Validation is my least favorite part of development and I'm glad for anything that makes it easier.


ActiveRuleProviders.Providers.Add(new CastleValidatorRulesProvider());


Apr 29, 2009 at 11:37 AM
Glad you figured that bit out. I'm aware of a pressing need to improve the documentation to make this point clearer.
Sep 18, 2009 at 4:21 PM

I ran into this problem today!

I was using the dll's from the model binder found here:

They don't play nice with xVal.  I swapped it out for the regular dll  and now it works great.

I figured I'd post this incase anyone else ran into the problem.