Data::Type::Facet - a subelement of a type
package Data::Type::Object::std_real; ... sub _test { my $this = shift; Data::Type::ok( 1, Data::Type::Facet::match( 'std/real' ) ); }
Facets are bric's for Data::Type::Object's. They are partially almost trivial (more or less), but have some advantages. They are modularising the testing procedure of any datatype (and therefore giving the magic to the "summary()" in Data::Type function.
Data::Type::Facet::Exception is thrown by any facet to indicate Data::Type that it failed to pass.
Data::Type::Facet::ref(); Data::Type::Facet::ref( 'ARRAY' ); # 'HASH' | 'CODE' | ..
Whether the value is a reference. If type is given, this explicit reference is required. So if $Data::Type::value = [ 1, 2 ] then
$Data::Type::value = [ 1, 2 ]
ok( 1, Data::Type::Facet::ref( 'ARRAY' ) );
would pass. While
ok( 1, Data::Type::Facet::ref( 'HASH' ) );
would of course not.
Data::Type::Facet::range( 1, 10 )
Value is numerically between the lower value x and upper limit value y (including them).
Counts the newlines \n in a textblock. Expects more then min lines (newlines).
\n
Counts the length() of a string and expects less than min.
length()
min
Expects numbers under the limit (< limit).
Expects numbers above limit (> limit).
Data::Type::Facet::match( 'std/word' );
Please visit "CONVENTIONS" in Data::Type::Docs::RFC and Regexp::Box for details registering regexps. All regexps used by Data::Type are stored within the central registry $Data::Type::rebox (Regexp::Box). The boxid must be therefore e prior registered to $Data::Type::rebox. The already stored one can be retrieven with Data::Type::Query.
$Data::Type::rebox
Expects an exact match (==).
==
Expects a defined value (as perl's defined()).
defined()
Expects not literally 'NULL'. Its test eq 'NULL'.
eq 'NULL'
Data::Type::Facet::bool( 'true' );
Expects true or false boolean value.
This function expects array elements with an array or a hash key within a hash, dependant on the given $Data::Type::value.
$Data::Type::value
Expects a number (mostly a credit-card number) to pass the mod10 LUHN algorithm check.
Sourceforge http://sf.net/projects/datatype is hosting a project dedicated to this module. And I enjoy receiving your comments/suggestion/reports also via http://rt.cpan.org or http://testers.cpan.org.
Murat Uenalan, <muenalan@cpan.org>
To install Data::Type, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Type
CPAN shell
perl -MCPAN -e shell install Data::Type
For more information on module installation, please visit the detailed CPAN module installation guide.