MooseX...traint(3pm)

πŸ“¦
version 0.21 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

MooseX::Params::Validate::Exception::ValidationFailedForTypeConstraint β€” bestie, this is the exception object that gets thrown when a type constraint check fails. That's it, that's the whole job, and she does it flawlessly. πŸŽ€

Oh and fyi, when you type man on this one your terminal shows the page as MooseX...traint(3pm) because it ran out of room for the whole name. Rude of it honestly, but that's her. πŸ¦‹


✨ VERSION ✨

version 0.21 β€” periodt. πŸ’…


🌸 SYNOPSIS 🌸

okay so here's the vibe in actual code, no cap:

use MooseX::Params::Validate qw( validated_list );
use Scalar::Util qw( blessed );
use Try::Tiny;

try {
    my @p = validated_list( @_, foo => { isa => 'Str' } );
}
catch {
    if (
        blessed $_
        && $_->isa(
            'MooseX::Params::Validate::Exception::ValidationFailedForTypeConstraint'
        )
        ) {
        ...;
    }
};

like, you run your validated_list, and if the type check goes sideways you catch it and check whether the thing you caught isa this class. If yes β€” congrats, it's her. 🌈


πŸ¦‹ DESCRIPTION πŸ¦‹

This class provides information about type constraint failures. She's the little info packet that shows up when something you passed didn't match what the type constraint wanted. Not me being obsessed with an exception class but here we are. πŸ’œ


πŸ‘‘ METHODS πŸ‘‘

This class provides the following methods:

  • $e->parameter() β€” returns a string describing the parameter. Like, something along the lines of "The 'foo' parameter" or "Parameter #1". It's giving "I know exactly which one of y'all did this". πŸ”₯
  • $e->value() β€” this is the actual value that failed the type constraint check. The culprit. The main character of the crime. 😭
  • $e->type() β€” this is the type constraint object that did not accept the value. She said no, respectfully. πŸ’€

⭐ STRINGIFICATION ⭐

This object stringifies to a reasonable error message. So if you just print her or drop her in a string, she'll tell you what went wrong. No extra work required, slay. 🫢


🌸 AUTHORS 🌸

  • Stevan Little <stevan@cpan.org>
  • Dave Rolsky <autarch@urth.org>

Icons. Both of them. πŸ‘‘


This software is copyright (c) 2013 - 2015 by Stevan Little <stevan@cpan.org>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


and that's the whole page, bestie!! πŸŽ€ this one came to you from perl v5.34.0, dated 2022-06-15, and your girl here is running on MooseX::Params::Validate version 0.21. mwah, go forth and validate. βœ¨πŸ’…

πŸ“¦ where this page comes from