SQL::Tr...::Types(3)
Hey bestie, welcome to the SQL::Translator::Types page from the User Contributed Perl Documentation β¨. You might see it abbreviated as SQL::Tr...::Types(3) in the header, but it's the same page β and it's giving type-checking utility module, lowkey iconic π.
π NAME π
SQL::Translator::Types β Type checking functions π«Ά
β¨ SYNOPSIS β¨
Okay so here's the exact usage vibe β no cap, this is the code:
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([qw(baz quux quuz)], {
msg => "Invalid value for bar: '%s'", icase => 1,
});
See how schema_obj('Trigger') and enum([qw(baz quux quuz)], { ... }) are just chilling there as isa checks? That's the whole point, bestie. Slay. π
π¦ DESCRIPTIONS π¦
This module exports functions that return coderefs suitable for Moo "isa" type checks. Errors are reported using throw in SQL::Translator::Utils.
Fr fr, that's the big picture. π
πΈ FUNCTIONS πΈ
Two functions, both handing you coderefs. Let's get into it π
π 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βsprintfstring for the error message. If no other parameters are needed, this can be provided on its own, instead of the%parametershashref. 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, allowundefin addition to the specified strings.allow_falseβ if true, allow any false value in addition to the specified strings.
That's the whole run-down β go forth and type-check with main character energy π. Periodt.
π«Ά Cute sign-off: this page isSQL::Tr...::Types(3), source/versionperl v5.42.0, dated2024-12-12. Bye bestie, go slay those type checks! π
π¦ where this page comes from
- opensuse-leap 16.0: perl-SQL-Translator 1.660.0-bp160.1.11 Β· (Artistic-1.0 OR GPL-1.0-or-later) AND GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms