Arthur Axel "fREW" Schmidt > SQL-Translator-0.11013_03 > SQL::Translator::Types

Download:
SQL-Translator-0.11013_03.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  62
Open  21
View/Report Bugs
Source   Latest Release: SQL-Translator-0.11018

NAME ^

SQL::Translator::Types - Type checking functions

SYNOPSIS ^

    package Foo;
    use Moo;
    use SQL::Translator::Types qw(schema_obj enum);

    has foo => ( is => 'rw', isa => schema_obj('Trigger') );
    has bar => ( is => 'rw', isa => enum([q(baz quux quuz)], {
        msg => "Invalid value for bar: '%s'", icase => 1,
    });

DESCRIPTIONS ^

This module exports fuctions that return coderefs suitable for Moo isa type checks. Errors are reported using "throw" in SQL::Translator::Utils.

FUNCTIONS ^

schema_obj($type)

Returns a coderef that checks that its arguments is an object of the class SQL::Translator::Schema::$type.

enum(\@strings, [$msg | \%parameters])

Returns a coderef that checks that the argument is one of the provided @strings.

Parameters

msg

sprintf string for the error message. If no other parameters are needed, this can be provided on its own, instead of the %parameters hashref. The invalid value is passed as the only argument. Defaults to Invalid value: '%s'.

icase

If true, folds the values to lower case before checking for equality.

allow_undef

If true, allow undef in addition to the specified strings.

allow_false

If true, allow any false value in addition to the specified strings.

syntax highlighting: