Skip to content
Discussion options

You must be logged in to vote

I tend to use something similar to this in the templates. I don't feel the full error message on validation belongs in the controller. That is more a template thing.

%= text_field 'foobar'
% if ( my $e = validation->has_error('foobar') ) {
    <div class="error">
    %= 'Required'     if $e->[0] eq 'required'
    %= ...
    </div>
% }

The validation system only spits out these markers (the name of the validation the failed). It is your job to write a suitable error message for it.

Using suitable helpers one can simplify to

%= text_field 'foobar'
%= validation_error 'foobar' => begin 
    %= 'Required'     if $_->[0] eq 'required'
    %= ...
% end

making the syntax much simpler.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Wail75
Comment options

@guest20
Comment options

@Wail75
Comment options

@guest20
Comment options

Answer selected by Wail75
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants