Skip to content

Commit

Permalink
stash
Browse files Browse the repository at this point in the history
  • Loading branch information
nics committed Mar 20, 2017
1 parent ee8f255 commit 5158ea0
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Catmandu/Fix/Condition/greater_than.pm
Expand Up @@ -27,7 +27,7 @@ __END__
=head1 NAME
Catmandu::Fix::Condition::greater_than - Excute fixes when a field is greater than a value
Catmandu::Fix::Condition::greater_than - Execute fixes when a field is greater than a value
=head1 SYNOPSIS
Expand Down
45 changes: 45 additions & 0 deletions lib/Catmandu/Fix/Condition/validate.pm
@@ -0,0 +1,45 @@
package Catmandu::Fix::Condition::validate;

use Catmandu::Sane;

our $VERSION = '1.0306';

use Moo;
use Catmandu::Util qw(require_package)
use namespace::clean;
use Catmandu::Fix::Has;

has path => (fix_arg => 1);
has name => (fix_arg => 1);
has opts => (fix_opt => 'collect');
has validator => (is => 'lazy', init_arg => undef);

with 'Catmandu::Fix::Condition::SimpleAllTest';

sub emit_test {
my ($self, $var) = @_;
my $validator_var = $fixer->capture($self->validator);

"${validator_var}\->is_valid(${var})";
}

sub _build_validator {
my ($self) = @_;
require_package($self->name, 'Catmandu::Validator')->new($self->opts);
}

1;

__END__
=pod
=head1 NAME
Catmandu::Fix::Condition::validate - Execute fixes if the data passes validation
=head1 SEE ALSO
L<Catmandu::Fix::Condition::validate>
=cut

0 comments on commit 5158ea0

Please sign in to comment.