9c49bc95652db7332558b88aadbb0c6024c58b6c
[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 -declare => [qw/NameSeparator QuoteChars AST/];
5   use MooseX::Types::Moose qw/ArrayRef Str Int Ref HashRef/;
6
7   subtype AST, as HashRef,
8     where { exists $_->{-type} && is_Str($_->{-type}) },
9     message { "No '-type' key, or it is not a string" };
10
11   subtype NameSeparator,
12     as Str,
13     where { length($_) == 1 };
14
15
16   subtype QuoteChars,
17     as ArrayRef[Str];
18     where { @$_ == 1 || @$_ == 2 },
19     message { "Quote characters must be one or two elements" };
20
21   coerce QuoteChars, from Str, via { [ split //, $_ ] };
22
23 }
24
25 1;