Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
#!/usr/bin/env perl
package Thingy;
use Moo;
use Types::Standard qw(Str Int HashRef ArrayRef Dict Tuple Optional);
has payload => (
is => 'rw',
isa => ArrayRef[
some_id => Int,
another_id => Int,
some_colour => Str,
yet_another_id => Optional[Int],
package main;
use Try::Tiny;
use Data::Dumper;
my $thingy = Thingy->new;
try {
{ some_id => 'Ten' },
catch {
warn $_;
warn Dumper( $_->explain );
warn "Moo: $Moo::VERSION";
warn "Types::Standard: $Types::Standard::VERSION";
[{"some_id" => "Ten"}] did not pass type constraint "ArrayRef[Dict[another_id=>Int,some_colour=>Str,some_id=>Int,yet_another_id=>Optional[Int]]]" at (eval 237) line 12.
$VAR1 = [
'[{"some_id" => "Ten"}] did not pass type constraint "ArrayRef[Dict[another_id=>Int,some_colour=>Str,some_id=>Int,yet_another_id=>Optional[Int]]]"',
'"ArrayRef[Dict[another_id=>Int,some_colour=>Str,some_id=>Int,yet_another_id=>Optional[Int]]]" constrains each value in the array with "Dict[another_id=>Int,some_colour=>Str,some_id=>Int,yet_another_id=>Optional[Int]]"',
'{"some_id" => "Ten"} did not pass type constraint "Dict[another_id=>Int,some_colour=>Str,some_id=>Int,yet_another_id=>Optional[Int]]" (in $_->[0])',
'"Dict[another_id=>Int,some_colour=>Str,some_id=>Int,yet_another_id=>Optional[Int]]" requires key "another_id" to appear in hash'
Moo: 1.002 at ./ line 35.
Types::Standard: 0.007_05 at ./ line 36.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.