Catman...:Simple(3pm)
β¨ 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
undefif 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
- ubuntu resolute: libcatmandu-perl 1.2025-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatmandu-perl 1.2025-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms