The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Data::Schema::Type::Schema - Make schema as type

VERSION

version 0.134

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.

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

Data::Schema::Manual::Schema

AUTHOR

  Steven Haryanto <stevenharyanto@gmail.com>

COPYRIGHT AND LICENSE

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.