HTML::...traint(3pm)

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

🌸 NAME 🌸

HTML::Widget::Constraint β€” Constraint Base Class πŸ’…

bestie, this is the page for HTML::...traint(3pm) (the manual's own little shorthand for it, don't @ me). It's the base class everything else in the constraint family is built on. πŸ‘‘


✨ SYNOPSIS ✨

my $c = $widget->constraint( $type, @names );
$c->message('Validation error.');
$c->names(@names);
$c->not(1);

πŸ’– DESCRIPTION πŸ’–

Constraint Base Class. That's it, that's the whole description. It's the blueprint, the mother of all constraints, the one who gave birth to the rest of them. 🫢


πŸŽ€ METHODS πŸŽ€

πŸ’« default_message

  • Arguments: $message
  • Return Value: $message

Default error message for failing constraints. Like, when a constraint fails and nobody bothered to set a custom message, this is the one that shows up. The default. The fallback. The "we had nothing better so here" of error messages. 😭

πŸ’« init

  • Arguments: $widget

Called once when process() gets called for the first time. One time only, bestie β€” the first process() and never again. πŸ’…

πŸ’« javascript

  • Arguments: $id

Should return JavaScript for client side validation and the like. Yes girl, this is where the client-side magic is supposed to go. ✨

πŸ’« msg

πŸ’« message

  • Arguments: $message

Contains the validation error message. Both names, same job β€” pick whichever one feels right for your vibe. 🌈

πŸ’« mk_message

  • Arguments: $message

Returns a validation error message. It makes the message. Iconic behavior, truly. πŸŽ€

πŸ’« names

  • Arguments: @names
  • Return Value: @names

Contains names of params to test. These are the ones getting the vibe check. 🧚

πŸ’« not

  • Arguments: $bool
  • Return Value: $bool

Negate constraint. Flip it. Whatever the constraint says, do the opposite. Main character energy but make it boolean. πŸ”₯

πŸ’« prepare

  • Arguments: $widget

Called every time process() gets called. Every. Single. Time. Unlike init, this one shows up to every party, no skipping. πŸ¦‹

πŸ’« process

  • Arguments: $widget, $params, \@uploads
  • Return Value: \@errors

Validates params and returns a arrayref containing HTML::Widget::Error objects representing failed constraints. So like, it checks your stuff, and if your stuff failed, you get back a whole arrayref full of little error objects documenting every single way you messed up. No cap. πŸ’€

πŸ’« process_js

  • Arguments: $id

Returns a hashref containing JavaScripts for client side validation and the like. The JS twin of process, basically β€” hashref flavored. ⭐

πŸ’« render_errors

  • Arguments: @names

A list of element names for which an error should be displayed.

If this is not set, the default behaviour is for the error to be displayed for all of the Constraint's named elements. So if you don't say anything, it just shows errors for everything the Constraint is named after. Loud and proud, no filter. πŸ“£

πŸ’« validate

  • Arguments: $value
  • Return Value: $bool

Validates a value and returns 1 or 0. Yes or no. Slay or nay. That's the whole API. πŸ‘‘


πŸ‘‘ AUTHOR πŸ‘‘

Sebastian Riedel, "sri@oook.de" β€” the legend himself. 🫢


πŸ“œ LICENSE πŸ“œ

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. Free as in bestie, go wild. πŸ’–


okay and that's the whole page, mwah πŸ’‹ β€” this was perl v5.36.0, dated 2023-08-10, on the HTML::...traint(3pm) manual page. thanks for coming to my ted talk, now go validate something. βœ¨πŸŽ€

πŸ“¦ where this page comes from