1 package SQL::Translator::Types;
5 SQL::Translator::Types - Type checking functions
11 use SQL::Translator::Types qw(schema_obj);
13 has foo => ( is => 'rw', isa => schema_obj('Trigger') );
17 This module exports fuctions that return coderefs suitable for L<Moo>
19 Errors are reported using L<SQL::Translator::Utils/throw>.
25 use SQL::Translator::Utils qw(throw);
26 use Scalar::Util qw(blessed);
28 use Exporter qw(import);
29 our @EXPORT_OK = qw(schema_obj);
33 =head2 schema_obj($type)
35 Returns a coderef that checks that its arguments is an object of the
36 class C<< SQL::Translator::Schema::I<$type> >>.
43 $class = 'SQL::Translator::Schema' . ($class eq 'Schema' ? '' : "::$class");
45 throw("Not a $name object")
46 unless blessed($_[0]) and $_[0]->isa($class);