Skip to content

Instantly share code, notes, and snippets.

@moznion
Created June 12, 2017 03:29
Show Gist options
  • Save moznion/afe57cfcbdf89727406fcc9a7b286200 to your computer and use it in GitHub Desktop.
Save moznion/afe57cfcbdf89727406fcc9a7b286200 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use feature qw/state say/;
use Data::Validator;
package Foo {
sub build {
state $rule = Data::Validator->new(
item => {isa => 'Bar|Buz'},
)->with('Method');
my ($class, $argument) = $rule->validate(@_);
say 'OK';
}
}
package Bar {
sub new {
bless {}, $_[0];
}
}
package Buz {
sub new {
bless {}, $_[0];
}
}
Foo->build({item => Bar->new});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment