NAME
MooX::Validate - Minimalist Data Validation for Moo
VERSION
version 0.000003
SYNOPSIS
package Cat::Food;
use Moo;
use MooX::Validate;
has brand => (
is => 'ro',
validate => {
options => ['SWEET-TREATZ', 'TREATZ-THATR-SWEET', 'NOM-NOMS'],
filters => ['trim', 'strip'],
}
);
has pounds => (
is => 'rw',
validate => {
error => "less than 15 pounds, are you nuts?",
filters => ['trim','strip', 'numeric'],
min_sum => 15,
}
);
package main;
my $food = Cat::Food->new(brand => 'NOM-NOMS', pounds => 20);
$food->pounds(' p1oy5 '); # YIPPEE
$food->pounds(10); # KABOOM
1;
DESCRIPTION
MooX::Validate is mashup between Validation::Class::Simple, a wrapper around
the Validation::Class library, which provides minimalist validation and
filtering automation, and Moo. Validation::Class is a robust data validation
library that ships with a complete set of pre-defined validations and filters
referred to as directives. Moo is an
extremely light-weight subset of Moose optimised for rapid startup and
"pay only for what you use". It also avoids depending on any XS modules to allow
simple deployments. The name Moo
is based on the idea that it provides almost
but not quite two thirds of Moose.
METHODS
validator
The validator method gives you access to a Validation::Class::Simple object using the pre-declared validation rules defined in the attribute declarations. See Validation::Class::Simple for more information on utilizing this object.
my $validator = $self->validator;
$validator->validate(@specifically);
AUTHOR
Al Newkirk anewkirk@ana.io
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Al Newkirk.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.