NAME
Poz::Types::object - A module for handling structured data with type validation
SYNOPSIS
use Poz qw/z/;
my $object = z->object({
name => z->string,
age => z->number,
})->as('Some::Class');
my $parsed_data = $object->parse($data);
DESCRIPTION
Poz::Types::object is a module for handling structured data with type validation. It allows you to define a structure with specific types and validate data against this structure.
METHODS
as
$object->as($typename);
Sets the class name to bless the parsed data into. The $typename
parameter should be a string representing the class name.
parse
my $parsed_data = $object->parse($data);
Parses and validates the given data against the structure. If the data is valid, it returns the parsed data. If the data is invalid, it throws an exception with the validation errors.
safe_parse
my ($valid, $errors) = $object->safe_parse($data);
Parses and validates the given data against the structure. If the data is valid, it returns the parsed data and undef for errors. If the data is invalid, it returns undef for valid data and an array reference of errors.
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>