Regardless of what you do to validate, you're still going to have to
have some logic to loop through the fields to extract the data, as
only your program knows how to interpret that form post, and as that
logic is based on the form I think it does make sense to have that in
a controller. You may want to refactor it out into a base controller
or a helper object which gets injected into the controller, but I do
think it belongs in the controller's domain.
As for doing the actual validation, how about something like this:
Inside the loop, create an instance of an object, populate it with the
values from the row, then pass it to VT to validate? You could also
look at using the isValidObject validator
(http://www.validatethis.org/docs/wiki/Validation_Types_Supported_By_ValidateThis.cfm#IsValidObject)
by creating a container object and then loading each of these single
row objects into it, and then passing the whole thing to VT.
Bob
> --
> You received this message because you are subscribed to the Google Groups
> "ValidateThis" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/validatethis/-/loXX8JhNZb8J.
> To post to this group, send email to valida...@googlegroups.com.
> To unsubscribe from this group, send email to
> validatethis...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/validatethis?hl=en.
--
Bob Silverberg
www.silverwareconsulting.com
Good call on the looping - I may look at building a customer populateModel() type method that deals with utterable collections based on some form of naming convention on the fields.
And as you're saying, this could effectively populate a custom object that represents the form, that could then employ it's own validation method.
Hmmm I like this ideas - may work up some simple tests and see if I can get something working.
What I really want to try and escape is having to build a custom collection, populator, object and validation rule set for each form, however, this might just not be viable.
Robert
Bob
--
Bob Silverberg
www.silverwareconsulting.com