Catman...:Simple(3pm)

πŸ“¦
version 1.2025 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

✨ NAME ✨

Catmandu::Validator::Simple β€” the Simple Validator for Catmandu, bestie πŸ’–

Like, it's in the Catman...:Simple(3pm) manual section, so if you were looking for her, you found her 🫢


🌸 SYNOPSIS 🌸

use Catmandu::Validator::Simple;

my $validator = Catmandu::Validator::Simple->new(
    handler => sub {
        $data = shift;
        return "error" unless $data->{title} =~ m/good title/;
        return;
    }
);

if ( $validator->is_valid($hashref) ) {
    save_record_in_database($hashref);
} else {
    reject_form($validator->last_errors);
}

πŸ’… DESCRIPTION πŸ’…

Catmandu::Validator::Simple</purl> is literally here for doing simple data validation in Catmandu. That's the whole vibe. No cap. ✨


πŸŽ€ CONFIGURATION πŸŽ€

handler

A function (yes, a coderef, your moment to shine πŸ‘‘) that takes a hash reference item as its argument.

The rules of the game, fr fr:

  • Should return undef if the record passes validation βœ…
  • Otherwise return an error or an arrayref of errors 🚩
  • Each error can be either:
    • a simple message string, or
    • a hashref to more detailed error information
ngl the "return undef for valid" thing is the whole plot twist β€” don't forget it or your valid records will be out here getting rejected 😭

πŸ¦‹ SEE ALSO πŸ¦‹

See Catmandu::Validator for inherited methods, common configuration options, and usage. iykyk πŸ’œ


okay that's the page bestie, slay πŸ’– β€” this was perl v5.40.1, dated 2026-01-24, and that's the whole Catman...:Simple(3pm) moment. periodt. πŸŽ€βœ¨

πŸ“¦ where this page comes from