Skip to content

Instantly share code, notes, and snippets.

@kga
Created January 27, 2012 04:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kga/1687001 to your computer and use it in GitHub Desktop.
Save kga/1687001 to your computer and use it in GitHub Desktop.
#!/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