On Mar 13, 2008, at 10:49 AM, Carl Franks wrote:
On 06/03/2008, Andreas Marienborg <[EMAIL PROTECTED]> wrote:
To follow up even further, what is the rationale behind validators
only running if all constraints pass? It makes for a rather
unintuitive process for the users? They get 3 red boxes, fix them,
and
_then_ get another red box on something that seemed fine.
I can understand validators only running for fields where constraints
pass, but only after all seems a bit strange.
I originally made each step (constraints, inflators, validators,
transformers) an "all or nothing" effort because:
- firstly for inflators - they could be considered relatively
expensive, and so if there's any constraint errors on *any* fields,
you'll probably just be re-displaying the form again, and so probably
wouldn't want any inflators run.
- validators - I originally thought would be used for higher-level
"business logic" involving multiple fields. If you're needing to
validate on a single field, and it doesn't need inflated - then you
may be as well using a Constraint instead.
If you wanted validators to run if there's constraint errors on
unrelated fields, there would need to be a mechanism for the validator
to state which other fields should also be error-free (much like
others() on some constraints).
I think this would probably be a bit too much complexity, and error
prone, as the field list would need to be kept in sync with the
validation code.
Currently the only validator is HTML::FormFu::Validator::Imager::Size.
I've never yet needed to write any custom validators.
I hope this explains how we got where we are :)
Then may I suggest rewording the documentation?
"Validators are intended for higher-level validation, such as business-
logic and database constraints such as "is this username unique?"."
Which is exactly what I had in a Constraint, until I read that section
and figured it should probably be a Validator instead.
I'll just goahead and change my validators back to Constraints again
then :)
thanks for the response!
- andreas
_______________________________________________
HTML-FormFu mailing list
[email protected]
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu