NAME
Data::Schema::Type::Schema - Make schema as type
SYNOPSIS
# write schemas and store them in hashes (or files, or objects, ...)
my $schemas = {
even_int => [int => {divisible_by=>2}],
positive_even => [even_int => {min=>0}],
};
use Data::Schema;
my $ds = Data::Schema->new(
plugins=>['Data::Schema::Plugin::LoadSchema::Hash']
);
$n->config->schema_search_path([$schemas]);
my $res;
$res = $ds->validate(-2, 'even_int'); # success
$res = $ds->validate(-2, 'positive_even'); # fail
$res = $ds->validate(4, [even_int=>{divisible_by=>3}]); # fail
$res = $ds->validate(6, [even_int=>{divisible_by=>3}]); # success
DESCRIPTION
This is the type handler that makes a schema available as type in other schemas. What this basically does is that you can reuse a schema in other schemas.
Implementation-wise, this is the only type not deriving from Data::Schema::Type::Base.
To load schemas, either from a hash or YAML files, see Data::Schema::Plugin::LoadSchema::Hash or Data::Schema::Plugin::LoadSchema::YAMLFile.
TYPE ATTRIBUTES
The type attributes available are whatever attributes are available for the base type.
SEE ALSO
AUTHOR
Steven Haryanto, <steven at masterweb.net>
COPYRIGHT & LICENSE
Copyright 2009 Steven Haryanto, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.