Skip Menu |

This queue is for tickets about the MojoX-Validator CPAN distribution.

Report information
The Basics
Id: 79189
Status: new
Priority: 0/
Queue: MojoX-Validator

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

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



Subject: Improve testability with Test::Mojo
After working on an app that I wanted to vigorously test with Test::Mojo, I found it difficult checking input/error messages for forms with multiple fields. This might not be the best way to do it, but I modified the validate_error helper so I could get at the full error text for the field using ->text_is(): $self->helper( # Override validator_error to make it easier to check error messages # for specific form fields. validator_error => sub { my $self = shift; my $name = shift; return unless my $errors = $self->stash('validator_errors'); return unless my $message = $errors->{$name}; return $self->tag( 'div' => class => "error", id => "${name}_error" => sub {$message} ); } ); This obviously assumes that people will not call validator_error more than once, so adding it as another class name ${name}_error might be better suited. Cheers, -Paul