package App::Sqitch::Types; use 5.010; use strict; use warnings; use utf8; use Type::Library 0.040 -base, -declare => qw( Sqitch Engine Target UserName UserEmail Plan Change ChangeList LineList Tag Depend DateTime URI URIDB File Dir Config DBH ); use Type::Utils -all; use Types::Standard -types; use Locale::TextDomain 1.20 qw(App-Sqitch); use App::Sqitch::X qw(hurl); use App::Sqitch::Config; use Scalar::Util qw(blessed); use List::Util qw(first); our $VERSION = 'v1.3.0'; # VERSION # Inherit standard types. BEGIN { extends 'Types::Standard' }; class_type Sqitch, { class => 'App::Sqitch' }; class_type Engine, { class => 'App::Sqitch::Engine' }; class_type Target, { class => 'App::Sqitch::Target' }; class_type Plan, { class => 'App::Sqitch::Plan' }; class_type Change, { class => 'App::Sqitch::Plan::Change' }; class_type ChangeList, { class => 'App::Sqitch::Plan::ChangeList' }; class_type LineList, { class => 'App::Sqitch::Plan::LineList' }; class_type Tag, { class => 'App::Sqitch::Plan::Tag' }; class_type Depend, { class => 'App::Sqitch::Plan::Depend' }; class_type DateTime, { class => 'App::Sqitch::DateTime' }; class_type URIDB, { class => 'URI::db' }; class_type Config { class => 'App::Sqitch::Config' }; class_type File { class => 'Path::Class::File' }; class_type Dir { class => 'Path::Class::Dir' }; class_type DBH { class => 'DBI::db' }; subtype UserName, as Str, where { hurl user => __ 'User name may not contain "<" or start with "["' if /^[[]/ || / __ 'User email may not contain ">"' if />/; 1; }; # URI can be URI or URI::Nested. declare name => URI, constraint => sub { my $o = $_; return blessed $o && first { $o->isa($_)} qw(URI URI::Nested URI::WithBase) }; 1; __END__ =head1 Name App::Sqitch::Types - Definition of attribute data types =head1 Synopsis use App::Sqitch::Types qw(Bool); =head1 Description This module defines data types use in Sqitch object attributes. Supported types are: =over =item C An L object. =item C An L object. =item C An L object. =item C A Sqitch user name. =item C A Sqitch user email address. =item C A L object. =item C A L object. =item C A L object. =item C A L object. =item C A L object. =item C A L object. =item C A L object. =item C A L object. =item C A L object. =item C A C object. =item C A C object. =item C A L object. =item C A L database handle. =back =head1 Author David E. Wheeler =head1 License Copyright (c) 2012-2022 iovation Inc., David E. Wheeler Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =cut