NAME
Poz::Types::array - Array type validation for Poz::Types
SYNOPSIS
use Poz qw/z/;
my $array_validator = z->array(z->number);
$array_validator->min(1)->max(5)->nonempty();
my $data = [1, 2, 3];
my $validated_data = $array_validator->parse($data);
DESCRIPTION
Poz::Types::array provides a way to validate arrays with various rules. It is designed to work with the Poz.
METHODS
as
$array_validator->as('ArrayClass');
Sets the class name to bless the validated array into.
parse
my $validated_data = $array_validator->parse($data);
Parses and validates the data. Throws an exception if validation fails.
safe_parse
my ($validated_data, $errors) = $array_validator->safe_parse($data);
Parses and validates the data. Returns the validated data and any errors.
min
$array_validator->min($min_length);
Sets a minimum length for the array.
max
$array_validator->max($max_length);
Sets a maximum length for the array.
length
$array_validator->length($exact_length);
Sets an exact length for the array.
nonempty
$array_validator->nonempty();
Ensures the array is not empty.
element
my $element_validator = $array_validator->element();
Returns the element validator.
LICENSE
Copyright (C) ytnobody.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
ytnobody <ytnobody@gmail.com>