Data::Schema::Type::Either - Type handler for 'either' type
version 0.134
use Data::Schema;
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
Either is Scalar, so you might want to consult the docs of those roles to see what type attributes are available.
Specify the schema(s), where the value will need to be valid to one of them.
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.