cascade-dataform Mailing List for Cascade
Status: Inactive
Brought to you by:
markjugg
You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(1) |
Feb
(5) |
Mar
|
Apr
|
May
(3) |
Jun
(2) |
Jul
|
Aug
(9) |
Sep
(24) |
Oct
(7) |
Nov
(20) |
Dec
(3) |
2003 |
Jan
(5) |
Feb
(1) |
Mar
(10) |
Apr
(56) |
May
(14) |
Jun
(8) |
Jul
(4) |
Aug
(3) |
Sep
(20) |
Oct
(14) |
Nov
(6) |
Dec
(5) |
2004 |
Jan
(13) |
Feb
(33) |
Mar
(33) |
Apr
(23) |
May
(11) |
Jun
(5) |
Jul
(7) |
Aug
(20) |
Sep
(14) |
Oct
(26) |
Nov
(5) |
Dec
(3) |
2005 |
Jan
(2) |
Feb
(5) |
Mar
(22) |
Apr
(32) |
May
(33) |
Jun
(14) |
Jul
(26) |
Aug
(49) |
Sep
(11) |
Oct
(84) |
Nov
(4) |
Dec
(43) |
2006 |
Jan
(8) |
Feb
(9) |
Mar
(23) |
Apr
(2) |
May
(19) |
Jun
(10) |
Jul
(2) |
Aug
(23) |
Sep
(8) |
Oct
(24) |
Nov
(11) |
Dec
(10) |
2007 |
Jan
(3) |
Feb
(2) |
Mar
(1) |
Apr
(5) |
May
(1) |
Jun
(1) |
Jul
(3) |
Aug
(6) |
Sep
(7) |
Oct
(7) |
Nov
(7) |
Dec
(12) |
2008 |
Jan
(6) |
Feb
(5) |
Mar
|
Apr
(7) |
May
(3) |
Jun
(6) |
Jul
(4) |
Aug
(6) |
Sep
|
Oct
|
Nov
(1) |
Dec
(2) |
2009 |
Jan
(1) |
Feb
(3) |
Mar
(3) |
Apr
(1) |
May
(11) |
Jun
(7) |
Jul
(3) |
Aug
(2) |
Sep
(1) |
Oct
|
Nov
(4) |
Dec
|
2010 |
Jan
(4) |
Feb
|
Mar
(12) |
Apr
(1) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(11) |
2011 |
Jan
|
Feb
(3) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Todd W. <tr...@sb...> - 2017-01-27 07:29:30
|
Hello, I have the beginnings of a module that extends dfv to allow validation of complex data structures. https://github.com/trwww/perl-dataformvalidator-multi I'll be sending this to CPAN probably this weekend unless anyone has feedback before then. Thanks! |
From: David W. <dav...@va...> - 2016-08-07 19:01:45
|
Thanks I ended up using FV_and from Data::FormValidator::Constraints::MethodsFactory to define constraint methods on my email field as follows. email => [ { constraint_method => email , name => 'email_valid' } , { constraint_method => FV_and ( email , representative_known ( $self -> dbh ) ) , fields => [ qw / society / ] , name => 'representative_known' } , ] , The email method executes twice but the representative_known method only executes if the email method confirms that the email provided has a valid format. I didn't want the representative_known method to execute if the email is invalid as that would be a wasteful database access. Dave On 11/07/16 08:57, Jonas B. Nielsen wrote: > Hi Dave. > > Not the prettiest solution. but you could do a two phase validation: > > my $dfv = Data::FormValidator->new({ > profile_1 => { # usual profile definition here }, > profile_2 => { # another profile definition }, > }); > > my $results1 = $dfv->check(\%input_hash,'profile_1’); > > my $results2 = $dfv->check(\%input_hash,'profile_2'); > > Examples lifted from the documentation: > > https://metacpan.org/pod/Data::FormValidator > > jonasbn > >> On 11 Jul 2016, at 01:44, David Williamson <dav...@va...> wrote: >> >> I have a form field "email". I want to apply two constraints to it. >> Firstly, I want to check that the email entered looks valid. Secondly, >> if (and only if) the email entered looks valid I want to check that is >> known to be associated with a society. That second check is specific to >> the particular functionality of my web site. >> >> Here is my entry for the email field in constraint_methods. >> >> email => [ >> { >> constraint_method => email , >> name => 'email_valid' >> } , >> { >> constraint_method => representative_known , >> fields => [ qw / society / ] >> } , >> ] , >> >> I've used the email constraint from Data::FormValidator::Constraints and >> provided my own name to associate to my own error message. I have >> another error message associated with the representative_known constraint. >> >> When I test with an invalid email address I get both error messages >> returned in an array, which suggests to me that both constraints have >> been executed. How do I stop the representative_known constraint from >> being run if the email fails the email constraint? >> >> Dave >> >> >> ------------------------------------------------------------------------------ >> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San >> Francisco, CA to explore cutting-edge tech and listen to tech luminaries >> present their vision of the future. This family event has something for >> everyone, including kids. Get more information and register today. >> http://sdm.link/attshape >> _______________________________________________ >> Cascade-DataForm mailing list >> Cas...@li... >> https://lists.sourceforge.net/lists/listinfo/cascade-dataform |
From: Jonas B. N. <jo...@gm...> - 2016-07-11 07:57:18
|
Hi Dave. Not the prettiest solution. but you could do a two phase validation: my $dfv = Data::FormValidator->new({ profile_1 => { # usual profile definition here }, profile_2 => { # another profile definition }, }); my $results1 = $dfv->check(\%input_hash,'profile_1’); my $results2 = $dfv->check(\%input_hash,'profile_2'); Examples lifted from the documentation: https://metacpan.org/pod/Data::FormValidator jonasbn > On 11 Jul 2016, at 01:44, David Williamson <dav...@va...> wrote: > > I have a form field "email". I want to apply two constraints to it. > Firstly, I want to check that the email entered looks valid. Secondly, > if (and only if) the email entered looks valid I want to check that is > known to be associated with a society. That second check is specific to > the particular functionality of my web site. > > Here is my entry for the email field in constraint_methods. > > email => [ > { > constraint_method => email , > name => 'email_valid' > } , > { > constraint_method => representative_known , > fields => [ qw / society / ] > } , > ] , > > I've used the email constraint from Data::FormValidator::Constraints and > provided my own name to associate to my own error message. I have > another error message associated with the representative_known constraint. > > When I test with an invalid email address I get both error messages > returned in an array, which suggests to me that both constraints have > been executed. How do I stop the representative_known constraint from > being run if the email fails the email constraint? > > Dave > > > ------------------------------------------------------------------------------ > Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San > Francisco, CA to explore cutting-edge tech and listen to tech luminaries > present their vision of the future. This family event has something for > everyone, including kids. Get more information and register today. > http://sdm.link/attshape > _______________________________________________ > Cascade-DataForm mailing list > Cas...@li... > https://lists.sourceforge.net/lists/listinfo/cascade-dataform |
From: David W. <dav...@va...> - 2016-07-11 00:24:41
|
I have a form field "email". I want to apply two constraints to it. Firstly, I want to check that the email entered looks valid. Secondly, if (and only if) the email entered looks valid I want to check that is known to be associated with a society. That second check is specific to the particular functionality of my web site. Here is my entry for the email field in constraint_methods. email => [ { constraint_method => email , name => 'email_valid' } , { constraint_method => representative_known , fields => [ qw / society / ] } , ] , I've used the email constraint from Data::FormValidator::Constraints and provided my own name to associate to my own error message. I have another error message associated with the representative_known constraint. When I test with an invalid email address I get both error messages returned in an array, which suggests to me that both constraints have been executed. How do I stop the representative_known constraint from being run if the email fails the email constraint? Dave |
From: Jiří P. <ji...@ge...> - 2014-04-15 10:48:53
|
Hi, for a profile that validates a select field, which can have multiple options selected I'd like the results hash to contain an empty array ref if no option is selected. Is this possible? Thank you, Jiri -- Jiří Pavlovský |
From: Jiří P. <ji...@ge...> - 2013-03-12 12:52:55
|
Hi, I'd like to use 'defaults' in my profile to set value on a field in case it was empty. But the default overrided the user provided value. So how can I achieve my goal? Thank you, -- Jiří Pavlovský |
From: Mark S. <ma...@su...> - 2012-04-25 13:02:18
|
On 04/24/2012 12:16 PM, Louis-David Mitterrand wrote: > Hi, > > I'm a bit stuck here. > > Among this 'require_some' entry, I need at least one of them to return a > 1 value. These are individual checkboxes that return either 0 > (defaults_regexp_map) or 1 (when checked). > > require_some => { > notify=>[1, qw/notify_down notify_up notify_new notify_gone notify_back/], > }, > > defaults_regexp_map => { > qr/^notify_/ => 0, > }, > > How can I specify a constraint that would kick in when all the 'notify' > values are 0? Constraints must always be tied to a single field. So, you would arbitrary pick one of the fields to apply the constraint to, like notify_down. You would then write a custom constraint for it, and the constraint would only return success if all the notify values were zero. Here's the section on writing custom constraints: https://metacpan.org/module/Data::FormValidator::Constraints#WRITING-YOUR-OWN-CONSTRAINT-ROUTINES Mark |
From: Louis-David M. <vin...@ap...> - 2012-04-24 16:33:11
|
Hi, I'm a bit stuck here. Among this 'require_some' entry, I need at least one of them to return a 1 value. These are individual checkboxes that return either 0 (defaults_regexp_map) or 1 (when checked). require_some => { notify=>[1, qw/notify_down notify_up notify_new notify_gone notify_back/], }, defaults_regexp_map => { qr/^notify_/ => 0, }, How can I specify a constraint that would kick in when all the 'notify' values are 0? Thanks, |
From: Matt <ma...@cp...> - 2011-03-23 14:47:27
|
Hi All, I've been working on putting together a somewhat simple on-the-fly DFV profile generator, but have hit a bit of a roadblock. I am trying to attach multiple constraints to a given field with a profile like so : { constraint_methods => { username => [ sub { ... }, sub { ... }, qr/^\W+$/, { constraint => qr/^\W+$/, name => "username_valid" }, { constraint => sub { ... }, name => "username_length" }, { constraint => sub { ... }, name => "username_taken" }, ], }, required => "username", } Based on the documentation here: http://search.cpan.org/~markstos/Data-FormValidator-4.66/lib/Data/FormValidator.pm#MULTIPLE_CONSTRAINTS I am led to believe this should be possible.. but I'm catching the following error: [error] Caught exception in SalesLink::Controller::Form->field "Value for constraint_method within hashref '' not a code reference or Regexp . Do you need func(), not 'func'? at /home/matt/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Data/FormValidator.pm line 974." Based on looking at D::FV's source it seems like this functionality is no longer supported, but I'd just like to confirm. Does anyone have any suggestions for approaching this issue? Cheers, Matt |
From: Jiří P. <ji...@ge...> - 2011-02-21 21:17:50
|
On 21.2.2011 15:45, Mark Stosberg wrote: > 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. > Thanks! |
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 |
From: Jiří P. <ji...@ge...> - 2011-02-20 20:09:19
|
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. Here is what I have: my $image_type_constraint = file_format(mime_types => ['image/png'] ); my $image_size_constraint = image_max_dimensions(200,200); ... constraint_methods => { photo_file => { constraint_method => sub { my ( $dfv, $photo_file, $main_web_photo,) = @_; return 0 unless $image_type_constraint->($dfv, $photo_file); if ($main_web_photo) { return 0 unless $image_size_constraint->($dfv, $photo_file); } return 1; }, params => [ qw( photo_file main_web_photo ) ], }, }, |
From: Jiří P. <ji...@ge...> - 2010-12-15 16:50:11
|
On 15.12.2010 15:36, Mark Stosberg wrote: >> I stripped my profile to the following test case. The optiona; value is >> not even amongst 'valid' fields. Did I misunderstood the ' >> missing_optional_valid' option? > Yes. It has a confusing detail when used in combination with checkboxes. > In fact, someone just ran into the same issue a few days ago. > > As the documentation for missing_optional_valid states, it is to cover > "optional fields with empty values". Despite the name, by intent it does > not cover completely missing values. The nature of checkboxes is > related-- unlike a text field a checkbox won't submit anything if it is > not checked. ( Rather than submitting the name with no value, there will > be nothing ). > > So, setting defaults in combination with checkboxes is recommended. It's > something I do myself. > Ok,thanks. Now I got it working. Regards, Jiri |
From: Mark S. <ma...@su...> - 2010-12-15 14:36:26
|
> I stripped my profile to the following test case. The optiona; value is > not even amongst 'valid' fields. Did I misunderstood the ' > missing_optional_valid' option? Yes. It has a confusing detail when used in combination with checkboxes. In fact, someone just ran into the same issue a few days ago. As the documentation for missing_optional_valid states, it is to cover "optional fields with empty values". Despite the name, by intent it does not cover completely missing values. The nature of checkboxes is related-- unlike a text field a checkbox won't submit anything if it is not checked. ( Rather than submitting the name with no value, there will be nothing ). So, setting defaults in combination with checkboxes is recommended. It's something I do myself. Mark |
From: Jiří P. <ji...@ge...> - 2010-12-14 22:09:07
|
On 14.12.2010 22:29, Mark Stosberg wrote: >> what I want to achieve is to filter checkbox values so that they are >> either 1 or 0, ie no undef values. >> >> So I put them into optional and set up field_filters for them with an >> sub like this >> >> sub checkbox_filter { >> return defined $_[0]&& lc $_[0] eq 'on' ? 1 : 0; >> } >> >> But it looks like the filed filters are never executed. > They should be working. Could you supply a Test::More test case that > shows they are not? Test::FormValidator may be useful. > > You could also post a version of your profile for us to review. I stripped my profile to the following test case. The optiona; value is not even amongst 'valid' fields. Did I misunderstood the ' missing_optional_valid' option? #!/usr/bin/perl use strict; use warnings; use Test::FormValidator; my $profile = { optional => [ 'approved'], filters => ['trim'], field_filters => { approved => sub { defined $_[0] && lc $_[0] eq 'on' ? 1 : 0; } }, missing_optional_valid => 1, }; use Test::More tests => 2; my $tfv = Test::FormValidator->new; $tfv->profile($profile); # check that the profile detects missing distribution_date $tfv->check(); $tfv->valid_ok(['approved'], 'Unchecked checkbox is valid'); my $results = $tfv->results; is($results->valid('approved'), 0, 'Unchecked checkbox is 0'); |
From: Mark S. <ma...@su...> - 2010-12-14 21:29:29
|
On 12/14/2010 08:29 AM, Jiří Pavlovský wrote: > Hi, > > what I want to achieve is to filter checkbox values so that they are > either 1 or 0, ie no undef values. > > So I put them into optional and set up field_filters for them with an > sub like this > > sub checkbox_filter { > return defined $_[0] && lc $_[0] eq 'on' ? 1 : 0; > } > > But it looks like the filed filters are never executed. They should be working. Could you supply a Test::More test case that shows they are not? Test::FormValidator may be useful. You could also post a version of your profile for us to review. Mark |
From: Jiří P. <ji...@ge...> - 2010-12-14 14:31:28
|
Hi, what I want to achieve is to filter checkbox values so that they are either 1 or 0, ie no undef values. So I put them into optional and set up field_filters for them with an sub like this sub checkbox_filter { return defined $_[0] && lc $_[0] eq 'on' ? 1 : 0; } But it looks like the filed filters are never executed. |
From: Mark S. <ma...@su...> - 2010-12-09 20:00:40
|
> OK, fair enough. But why do I have to add a 'defaults_regexp_map' in > order to get my missing optionnals in the 'valid' hash? Shouldn't the > 'missing_optional_valid' parameter do that? (notify_* are checkboxes) As the documentation for missing_optional_valid states, it is to cover "optional fields with empty values". Despite the name, by intent it does not cover completely missing values. The nature of checkboxes is related-- unlike a text field a checkbox won't submit anything if it is not checked. ( Rather than submitting the name with no value, there will be nothing ). So, setting defaults in combination with checkboxes is recommended. It's something I do myself. Mark |
From: Louis-David M. <vin...@ap...> - 2010-12-09 16:54:32
|
On Thu, Dec 09, 2010 at 11:49:30AM -0500, Mark Stosberg wrote: > On 12/09/2010 10:30 AM, Louis-David Mitterrand wrote: > > On Thu, Dec 09, 2010 at 10:24:03AM -0500, Mark Stosberg wrote: > >> On 12/09/2010 04:53 AM, Louis-David Mitterrand wrote: > >>> Hi, > >>> > >>> When using the $profile below, the 'missing_optional_valid' entries are > >>> never included in the valid hash. Specifically the notify_* checkboxes > >>> in require_some are never returned when unchecked. Did I miss something? > >> > >> What happens if you add all of the "require_some" fields explicitly to > >> an "optional" definition? > > > > Then it works, but only if I also add: > > > > defaults_regexp_map => { > > qr/^notify_/ => 0, > > }, > > > > Shouldn't the 'require_some' values that are not actually required (as > > per submit) be auto-added to 'optional'? > > Not necessarily. There are two cases for one could intend "require_some" > to be used: > > - At least one of five fields is required. We do not care about fields > which are not submitted. Either they are required are they are not in > the profile. > > - At least one of five fields is required. We would still like the > non-required fields to be returned as valid. > > I think it's reasonable to add require_some entires to optional if you > want them all through as "valid". OK, fair enough. But why do I have to add a 'defaults_regexp_map' in order to get my missing optionnals in the 'valid' hash? Shouldn't the 'missing_optional_valid' parameter do that? (notify_* are checkboxes) |
From: Mark S. <ma...@su...> - 2010-12-09 16:49:38
|
On 12/09/2010 10:30 AM, Louis-David Mitterrand wrote: > On Thu, Dec 09, 2010 at 10:24:03AM -0500, Mark Stosberg wrote: >> On 12/09/2010 04:53 AM, Louis-David Mitterrand wrote: >>> Hi, >>> >>> When using the $profile below, the 'missing_optional_valid' entries are >>> never included in the valid hash. Specifically the notify_* checkboxes >>> in require_some are never returned when unchecked. Did I miss something? >> >> What happens if you add all of the "require_some" fields explicitly to >> an "optional" definition? > > Then it works, but only if I also add: > > defaults_regexp_map => { > qr/^notify_/ => 0, > }, > > Shouldn't the 'require_some' values that are not actually required (as > per submit) be auto-added to 'optional'? Not necessarily. There are two cases for one could intend "require_some" to be used: - At least one of five fields is required. We do not care about fields which are not submitted. Either they are required are they are not in the profile. - At least one of five fields is required. We would still like the non-required fields to be returned as valid. I think it's reasonable to add require_some entires to optional if you want them all through as "valid". Mark |
From: Louis-David M. <vin...@ap...> - 2010-12-09 15:30:22
|
On Thu, Dec 09, 2010 at 10:24:03AM -0500, Mark Stosberg wrote: > On 12/09/2010 04:53 AM, Louis-David Mitterrand wrote: > > Hi, > > > > When using the $profile below, the 'missing_optional_valid' entries are > > never included in the valid hash. Specifically the notify_* checkboxes > > in require_some are never returned when unchecked. Did I miss something? > > What happens if you add all of the "require_some" fields explicitly to > an "optional" definition? Then it works, but only if I also add: defaults_regexp_map => { qr/^notify_/ => 0, }, Shouldn't the 'require_some' values that are not actually required (as per submit) be auto-added to 'optionnal'? |
From: Mark S. <ma...@su...> - 2010-12-09 15:24:10
|
On 12/09/2010 04:53 AM, Louis-David Mitterrand wrote: > Hi, > > When using the $profile below, the 'missing_optional_valid' entries are > never included in the valid hash. Specifically the notify_* checkboxes > in require_some are never returned when unchecked. Did I miss something? What happens if you add all of the "require_some" fields explicitly to an "optional" definition? Mark |
From: Louis-David M. <vin...@ap...> - 2010-12-09 09:53:42
|
Hi, When using the $profile below, the 'missing_optional_valid' entries are never included in the valid hash. Specifically the notify_* checkboxes in require_some are never returned when unchecked. Did I miss something? Thanks, my $profile = { ## for unchecked checkboxes missing_optional_valid => 1, required => [qw( id_rate ), ], require_some => { notify_down=>[1, qw/ notify_down notify_up notify_new notify_gone notify_back /], }, defaults => { id_cruise => $id_cruise, }, filters => ['trim'], msgs => { format => '%s', missing => "missing entry", }, }; |
From: Jiří P. <ji...@ge...> - 2010-08-03 11:01:04
|
Hello, how can I do the following: I have two fields and some fields that depend on them. THis set of dependent fields varies based on the values of both of the fields. I cannot figure out how to do to it with the dependencies option. Thank you, Jiri |
From: Mark S. <ma...@su...> - 2010-05-26 14:43:26
|
> How can I defer the second check until the first constraint validates? This is what "make_and_constraint()" is for. It's a very old feature, but I think it will work with newer-style constraint methods: http://search.cpan.org/~markstos/Data-FormValidator-4.66/lib/Data/FormValidator/ConstraintsFactory.pm#make_and_constraint(_@constraints_) Let us know if it doesn't. Mark |