51b834b6dc1722731e44487722dff144b2130337
[dbsrgits/SQL-Abstract-2.0-ish.git] / lib / SQL / Abstract / Types.pm
1 use MooseX::Declare;
2 class SQL::Abstract::Types {
3   use Moose::Util::TypeConstraints;
4   use MooseX::Types::Moose qw/ArrayRef Str Int Ref HashRef/;
5
6   clean;
7
8   use MooseX::Types -declare => [qw/NameSeparator QuoteChars AST/];
9
10   subtype AST, as HashRef,
11     where { exists $_->{-type} && is_Str($_->{-type}) },
12     message { "No '-type' key, or it is not a string" };
13
14   subtype NameSeparator,
15     as Str,
16     where { length($_) == 1 };
17
18
19   subtype QuoteChars,
20     as ArrayRef[Str];
21     where { @$_ == 1 || @$_ == 2 },
22     message { "Quote characters must be one or two elements" };
23
24   coerce QuoteChars, from Str, via { [ split //, $_ ] };
25
26 }
27
28 1;