Skip Menu |

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

Report information
The Basics
Id: 21274
Status: new
Priority: 0/
Queue: FormValidator-Simple

People
Owner: Nobody in particular
Requestors: claco [...] cpan.org
Cc:
AdminCc:

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



Subject: Ability to clear results messages between check calls to same FVS instance
By default, the messages/results created by the check method are additive between calls since the same results object is used. Sometimes this isn't the desired behavior. This patch adds a clear method to the results object that resets the result object to its initial 'success' state.
Subject: results_clear.patch
Index: lib/FormValidator/Simple/Results.pm =================================================================== --- lib/FormValidator/Simple/Results.pm (revision 3) +++ lib/FormValidator/Simple/Results.pm (working copy) @@ -177,6 +177,10 @@ } } +sub clear { + %{shift->_records} = (); +}; + 1; __END__ Index: t/05_results.t =================================================================== --- t/05_results.t (revision 3) +++ t/05_results.t (working copy) @@ -1,5 +1,5 @@ use strict; -use Test::More tests => 29; +use Test::More tests => 34; BEGIN{ use_ok("FormValidator::Simple::Results") } @@ -54,4 +54,9 @@ ok( exists $valids3->{r3}); is( $results->valid('r3'), 'data' ); - +$results->clear; +is(scalar keys %{$results->valid}, 0); +is(scalar @{$results->missing}, 0); +ok(!$results->has_error); +ok(!$results->has_invalid); +ok($results->success);