Data::Schema::Type::Schema - Make schema as type
version 0.134
# 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
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.
To load schemas, either from a hash or YAML files, see Data::Schema::Plugin::LoadSchema::Hash or Data::Schema::Plugin::LoadSchema::YAMLFile.
The type attributes available are whatever attributes are available for the base type.
Data::Schema::Manual::Schema
Steven Haryanto <stevenharyanto@gmail.com>
This software is copyright (c) 2009 by Steven Haryanto.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Data::Schema, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Schema
CPAN shell
perl -MCPAN -e shell install Data::Schema
For more information on module installation, please visit the detailed CPAN module installation guide.