Declar...Result(3pm)

πŸ“¦
version 0.03 Β· 5 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Declar...Result(3pm) πŸ’–

okay bestie, you're looking at Declare::Constraints::Simple::Result β€” the validation result page from the User Contributed Perl Documentation, no cap. It's giving "receipt for your vibes check". Let's go. ✨


🌸 NAME 🌸

Declare::Constraints::Simple::Result β€” Validation Result. That's it, that's the whole personality. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

my $result = $constraint->($value);

my $message = $result->message;
my $path    = $result->path;

like… you run the constraint, you get a result back, and then you can pull the message and the path out of it. iconic behavior fr fr. πŸ’…


✨ DESCRIPTION ✨

so this class is literally the whole result object that a Declare::Constraints::Simple constraint hands back to you when it's done judging your value. πŸ”₯

and here's the slay part: objects of this kind overload their boolean context. that means whatever is_valid() says gets reflected straight into the boolean-ness of the object itself. so you can just do if ($result) and the result is out here being its own truth-teller. main character energy, honestly. πŸ‘‘


πŸ’œ METHODS πŸ’œ

πŸŽ€ new()

Constructor. but listen β€” most of the time you're just receiving result objects, not making them, so you should literally never be required to call this yourself. it's the "you don't text first, they text you" of constructors. πŸ™ˆ

πŸ“ set_valid($bool)

Sets the result's validity flag. that's the whole job. πŸ’…

⭐ is_valid()

Boolean accessor. tells you if this is a true result or not. yes or no, valid or invalid, ate or didn't eat. periodt.

🌈 set_message($message)

The error message. ngl, this one's only useful on non-valid results β€” like, if everything's fine there's no drama to report. 😭

🧚 message()

Returns the message of the result object. the tea. the whole entire tea. 🫢

🌸 add_to_stack($constraint_name)

okay this one's a lil funky: it adds another level at the beginning (!) of the result's constraint stack. yes, the front, not the back, don't come for me. this is mostly intended to be used for the "prepare_generator" method in the Declare::Constraints::Simple::Library package. iykyk. ✨

πŸ’– path([$separator])

Returns a string containing the stack() contents joined together by the $separator string β€” and that separator defaults to ".". so like, if you don't pass anything, you get dots. cute, right? πŸŽ€

πŸ¦‹ stack()

Returns an array reference containing the result's currrent stack. yes i said "currrent", that's what the page says, we keep the lore. πŸ“œ

so this is a list of the constraints path parts. usually it's just the constraint's name. and if there's additional info, it gets appended to the name like "[$info]". so a path part might look like name[info]. slay. πŸ’œ


πŸ‘‘ SEE ALSO πŸ‘‘

  • Declare::Constraints::Simple

🫢 AUTHOR 🫢

Robert 'phaylon' Sedlacek "<phaylon@dunkelheit.at>"


This module is free software, you can redistribute it and/or modify it under the same terms as perl itself. so like, go off, just be normal about it. ✨


and that's the whole page bestie!! this one came from perl v5.32.0, dated 2021-01-09, and honestly? she ate. πŸ“πŸ’– bye mwah πŸ˜­πŸ’…
πŸ“¦ where this page comes from