HTML::...ckOnce(3pm)

πŸ“¦
version 1.11 Β· 3 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

HTML::Widget::Constraint::CallbackOnce β€” it's the CallbackOnce Constraint, and yes she's from the HTML::...ckOnce(3pm) manual, we love her, no cap 🫢


✨ SYNOPSIS ✨

    my $c = $widget->constraint( 'CallbackOnce', 'foo', 'bar' )->callback(
      sub {
        my ($foo, $bar) = @_;
        return 1 if $foo == $bar * 2;
      });

okay so that's literally it, you hand her a sub and she runs it. iconic behaviour fr fr πŸ’…


🌸 DESCRIPTION 🌸

So bestie, here's the tea: this is a callback constraint β€” but plot twist β€” it only gets run once for each call of process in HTML::Widget. Not twice. Not "hmm let me think about it again." Once. She said main character energy only, we're not doing reruns 😌✨


πŸŽ€ METHODS πŸŽ€

callback

cb

Arguments: \&callback

You require a subroutine reference here, and that's the thing doing your validation. When she calls it, she passes along a list of values that correspond to the constraint names. So like, the names you gave, the values show up in that same order. slay 🧚

Also β€” cb is provided as an alias to callback. Same girl, two nicknames, we contain multitudes πŸ’œ


process

This one overrides process in HTML::Widget::Constraint, and the whole point is to make sure validate is only called once for each call of validate. That's the assignment. That's the mission. periodt πŸ‘‘


render_errors

Arguments: @names

A list of element names for which an error should be displayed. Like, where do you want the sad little error message to show up, bestie?

If this is not set, the default behaviour is for the error to be displayed for all of the Constraint's named elements. Every single one. She's thorough like that πŸ¦‹


validate

perform the actual validation.

like, do the thing. the real work. the moment. the ✨validation✨ πŸ”₯


πŸ‘‘ AUTHOR πŸ‘‘

Carl Franks cfranks@cpan.org

(legend behaviour, we stan πŸ˜­πŸ’–)


πŸ’– LICENSE πŸ’–

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. So go off, remix her, she's free πŸ’…πŸŒΈ


and that's the whole page, bestie!! πŸŽ€ written up as part of the User Contributed Perl Documentation, perl v5.36.0, dated 2023-08-10. mwah, go validate something πŸ’‹βœ¨

πŸ“¦ where this page comes from