Skip to content

Instantly share code, notes, and snippets.

@kga
Created Jan 27, 2012
Embed
What would you like to do?
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Validator;
use Data::Dumper qw(Dumper);
my %rule = (
foo => { isa => 'Str' },
bar => { isa => 'Int' },
);
warn Dumper(\%rule);
my $v1 = Data::Validator->new(%rule);
warn Dumper(\%rule);
my $v2 = Data::Validator->new(%rule);
__END__
$ perl validator.pl
$VAR1 = {
'bar' => {
'isa' => 'Int'
},
'foo' => {
'isa' => 'Str'
}
};
$VAR1 = {
'bar' => {
'coerce' => '',
'name' => 'bar',
'type' => bless( {
'compiled_type_constraint' => sub { "DUMMY" },
'parent' => bless( {
'compiled_type_constraint' => sub { "DUMMY" },
'parent' => bless( {
'compiled_type_constraint' => sub { "DUMMY" },
'parent' => bless( {
'compiled_type_constraint' => sub { "DUMMY" },
'parent' => bless( {
'compiled_type_constraint' => sub { "DUMMY" },
'parent' => bless( {
'compiled_type_constraint' => sub { "DUMMY" },
'parent' => bless( {
'compiled_type_constraint' => $VAR1->{'bar'}{'type'}{'parent'}{'parent'}{'parent'}{'parent'}{'parent'}{'compiled_type_constraint'},
'name' => 'Any'
}, 'Mouse::Meta::TypeConstraint' ),
'name' => 'Item'
}, 'Mouse::Meta::TypeConstraint' ),
'hand_optimized_type_constraint' => $VAR1->{'bar'}{'type'}{'parent'}{'parent'}{'parent'}{'parent'}{'compiled_type_constraint'},
'name' => 'Defined'
}, 'Mouse::Meta::TypeConstraint' ),
'hand_optimized_type_constraint' => $VAR1->{'bar'}{'type'}{'parent'}{'parent'}{'parent'}{'compiled_type_constraint'},
'name' => 'Value'
}, 'Mouse::Meta::TypeConstraint' ),
'hand_optimized_type_constraint' => $VAR1->{'bar'}{'type'}{'parent'}{'parent'}{'compiled_type_constraint'},
'name' => 'Str'
}, 'Mouse::Meta::TypeConstraint' ),
'hand_optimized_type_constraint' => $VAR1->{'bar'}{'type'}{'parent'}{'compiled_type_constraint'},
'name' => 'Num'
}, 'Mouse::Meta::TypeConstraint' ),
'hand_optimized_type_constraint' => $VAR1->{'bar'}{'type'}{'compiled_type_constraint'},
'name' => 'Int'
}, 'Mouse::Meta::TypeConstraint' )
},
'foo' => {
'coerce' => '',
'name' => 'foo',
'type' => $VAR1->{'bar'}{'type'}{'parent'}{'parent'}
}
};
Wrong definition for 'bar': Unknown attributes: 'name' and 'type' at validator.pl line 16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment