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 β€” 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.

That's the whole run-down β€” go forth and type-check with main character energy πŸ‘‘. Periodt.

🫢 Cute sign-off: this page is SQL::Tr...::Types(3), source/version perl v5.42.0, dated 2024-12-12. Bye bestie, go slay those type checks! πŸ’–
πŸ“¦ where this page comes from