Commit | Line | Data |
cbcfedc1 |
1 | use MooseX::Declare; |
2 | class SQL::Abstract::Types { |
3 | use Moose::Util::TypeConstraints; |
4 | use MooseX::Types -declare => [qw/NameSeparator AST ArrayAST HashAST/]; |
5 | use MooseX::Types::Moose qw/ArrayRef Str Int Ref HashRef/; |
6 | |
7 | subtype ArrayAST, as ArrayRef, |
8 | where { is_Str($_->[0]) && substr($_->[0],0,1) eq '-' }, |
9 | message { "First key of arrayref must be a string starting with '-'"; }; |
10 | |
11 | subtype HashAST, as HashRef, |
12 | where { exists $_->{-type} && is_Str($_->{-type}) }, |
13 | message { "No '-type' key, or it is not a string" }; |
14 | |
15 | subtype AST, as ArrayAST|HashAST; |
16 | |
17 | subtype NameSeparator, |
18 | as ArrayRef[Str]; |
19 | #where { @$_ == 1 ||| @$_ == 2 }, |
20 | #message { "Name separator must be one or two elements" }; |
21 | |
22 | coerce NameSeparator, from Str, via { [ $_ ] }; |
23 | |
24 | } |
25 | |
26 | 1; |