Re: [dfv] Data::FormValidator::Constraints::Upload
Status: Inactive
Brought to you by:
markjugg
|
From: Mark S. <ma...@su...> - 2011-02-21 15:12:44
|
On 02/20/2011 02:38 PM, Jiří Pavlovský wrote: > Hello, > > I want to use Data::FormValidator::Constraints::Upload to validate photo > upload. I want to check the image type and optionally (based on other > parameter) its dimensions). > I'm not quite sure what is the best way to handle the optional > conditional constraint. > What I did was to store the constraint subroutines returned by the > appropriate methods in a variable and wrote my own constrain methods. > I'm just not sure whether it is the best approach. This looks Ok. If you want to have two constraints only have one be evaluated if the first one passes, than you might use make_and_constraint() from the ConstraintFactory module. Normally if you just define two constraints, DFV will evaluate both of them. For anything more complex, writing a custom constraint as you have done is a reasonable solution. Here's a link to the make_and_constraint() docs: http://goo.gl/iBjKo Mark |