Well, I've been able to create a bit of bolt on functionality for
Knockout that allows me to find out the elements bound to each
observable, and visa versa. With this functionality, I think I'll be
able to get automated server side validation working with KnockoutJS,
FluentValidation, MVC, and jQuery Validation. Here's what the process
looks like so far:
1) Submit the view model to the MVC Website as JSON.
2) FluentValidation on the server validates the model, and generates a
number of error messages in a key value format. These messages are
converted to JSON and are sent back to the client. The format of the
JSON object should look something like this:
[{ Key: 'ValueA', Message: "Field cannot be null" },
{ Key: 'NavPtyA.NavPtyB[0].ValueB', Message: "Field cannot be null" }]
3) Some client side scripting then processes each one of the
messages. For each message the Key of the message is used as the path
to traverse the Knockout View Model. Once the view model has been
traversed, we should have arrived at the observable that contains the
invalid data. At this stage we find out what html elements are mapped
to this observable, and then we flag them as invalid using the
showErrors() method in jQuery Validation.
When I get the chance I'll post a demo of this functionality on the
web.
Lucas