Steven Haryanto > Data-Schema-0.136 > Data::Schema::Type::Either

Download:
Data-Schema-0.136.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.136   Source  

NAME ^

Data::Schema::Type::Either - Type handler for 'either' type

VERSION ^

version 0.136

SYNOPSIS ^

 use Data::Schema;

DESCRIPTION ^

Aliases: or, any

'Either' is not really an actual data type, but a way to validate whether a value validates to any one of the specified schemas.

Example schema (in YAML syntax):

 - any
 - of:
     - [int, {divisible_by: 2}]
     - [int, {divisible_by: 7}]

Example valid data:

 42  # divisible by 2 as well as 7

 21  # not divisible by 2 but divisible by 7

 4   # not divisible by 7 but divisible by 2

Example invalid data:

 15 # not divisible by 2 nor 7

TYPE ATTRIBUTES ^

Either is Scalar, so you might want to consult the docs of those roles to see what type attributes are available.

of => [schema1, schema2, ...]

Specify the schema(s), where the value will need to be valid to one of them.

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.

syntax highlighting: