Skip Menu |

This queue is for tickets about the Data-FormValidator CPAN distribution.

Maintainer(s)' notes

This is the bug queue for Data::FormValidator.

Report information
The Basics
Id: 49477
Status: resolved
Priority: 0/
Queue: Data-FormValidator

People
Owner: MARKSTOS [...] cpan.org
Requestors: heinst [...] arqs.com.br
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Support for named constraints
I think it would be a good idea that the built in Constraints could be renamed using the idea of the named constraints so that we can use custom error messages more easily. I think it would be simple to change the default Constraints.pm and would not brake any existing code. For example, change in Constraints.pm FV_length_between from: sub FV_max_length { my ($max) = @_; croak "max is required" unless defined $max; return sub { my ($dfv,$value) = @_; $dfv->name_this('max_length'); return undef if ( length($value) > $max ); # Use a regexp to untaint $value=~/(.*)/; return $dfv->untainted_constraint_value($1); } } To: sub FV_max_length { my ($max) = @_; croak "max is required" unless defined $max; return sub { my ($dfv,$value) = @_; $dfv->name_this('max_length') unless $dfv->get_current_constraint_name(); return undef if ( length($value) > $max ); # Use a regexp to untaint $value=~/(.*)/; return $dfv->untainted_constraint_value($1); } }
Subject: Re: [rt.cpan.org #49477] Support for named constraints
Date: Tue, 8 Sep 2009 09:52:44 -0400
To: bug-Data-FormValidator [...] rt.cpan.org
From: Mark Stosberg <mark [...] summersault.com>
Show quoted text
> I think it would be a good idea that the built in Constraints could be > renamed using the idea of the named constraints so that we can use > custom error messages more easily.
It's an interesting idea. Please discuss it on the mailing list mentioned in the documentation to get more feedback. Mark
Thanks for the suggestion. I implemented this feature in 4.70, with credit to you.