---
name: "Catmandu::Validator::Simple"
section: "3pm"
platform: "linux"
package: "libcatmandu-perl"
version: "1.2024-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Catmandu::Validator::Simple"
---

# Catmandu::Validator::Simple(3pm)

Simple Validator for Catmandu

## NAME

Catmandu::Validator::Simple - Simple Validator for Catmandu

## 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 can be used for doing simple data validation in Catmandu.

## CONFIGURATION

- handler

  A function that takes a hash reference item as argument. 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 a more detailed error information.

## SEE ALSO

See Catmandu::Validator for inherited methods, common configuration options, and usage.
