Skip to content

Commit

Permalink
renamed is_submitted to has_data
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 27, 2013
1 parent 9bada75 commit 17ccd89
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions lib/Mojolicious/Validator/Validation.pm
Expand Up @@ -45,12 +45,12 @@ sub error {

sub errors { Mojo::Collection->new(@{shift->{errors}{shift()} // []}) }

sub has_data { !!keys %{shift->input} }

sub has_errors {
$_[1] ? exists $_[0]{errors}{$_[1]} : !!keys %{$_[0]{errors}};
}

sub is_submitted { !!keys %{shift->input} }

sub is_valid { exists $_[0]->output->{$_[1] // $_[0]->topic} }

sub optional {
Expand Down Expand Up @@ -177,19 +177,19 @@ Set custom error message for next validation check.
Return L<Mojo::Collection> object containing all error messages for failed
validation checks.
=head2 has_data
my $success = $validation->has_data;
Check if C<input> is available for validation.
=head2 has_errors
my $success = $validation->has_errors;
my $success = $validation->has_errors('foo');
Check if validation resulted in errors, defaults to checking all fields.
=head2 is_submitted
my $success = $validation->is_submitted;
Check if data has been submitted for validation.
=head2 is_valid
my $success = $validation->is_valid;
Expand Down
2 changes: 1 addition & 1 deletion t/mojolicious/validation_lite_app.t
Expand Up @@ -12,7 +12,7 @@ use Test::Mojo;
get '/' => sub {
my $self = shift;
my $validation = $self->validation;
return $self->render unless $validation->is_submitted;
return $self->render unless $validation->has_data;
$validation->required('foo')->size(2, 5);
$validation->optional('bar')->size(2, 5);
$validation->optional('baz')->size(2, 5);
Expand Down

0 comments on commit 17ccd89

Please sign in to comment.