Apache::Wyrd::Datum - Abstract data-checking objects for Wyrd Input objects
use Apache::Wyrd::Datum; my $ives = Apache::Wyrd::Datum::Set->new( 'kits', { options => ['kits', 'cats', 'sacks', 'wives'], not_null => 0 } ); my ($are_ostriches_ok, $why_not) = $ives->check('ostriches') my $is_cats = $ives->set('cats'); if ($is_cats) { print "yes, it can be cats" } else { print "no, cats are out" } my $suggest_something_then = $ives->suggest;
This module defines the following objects:
These objects are roughly tied to SQL data types and HTML inputs for providing data objects to higher-level objects. By abstracting the data class, the definintion of a "valid" value can be abstracted from the SQL or Wyrd device it will be used to check the values of.
These are used by Apache::Wyrd::Input-derived classes to check user-input.
Apache::Wyrd::Input
All Classes have the following methods:
my $data = Apache::Wyrd::Datum->new($value, \%params);
$data->set('value') #sets data to value (if strict, will return undef and fail to set)
my $value = $data->get('value'); #Return value (always a scalar)
$data->check('somevalue') #returns undef on invalid data. #Second returned param is an #[optional] error message.
$data->type #returns Data type: Char, Varchar, etc. in lower case
$data->suggest #returns a suggested value [if implemented].
Derived classes of Apache::Wyrd::Datum should override:
_type
_check_params
_check_value
And will probably want to override:
_default_value
_raise_exception
All Datum objects are initialized with
params: strict, length, not-null
params: strict, not-null
params: strict, not-null, options (arrayref of possible options)
Barry King <wyrd@nospam.wyrdwright.com>
Copyright 2002-2007 Wyrdwright, Inc. and licensed under the GNU GPL.
See LICENSE under the documentation for Apache::Wyrd.
Apache::Wyrd
3 POD Errors
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
'=item' outside of any '=over'
To install Apache::Wyrd, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Apache::Wyrd
CPAN shell
perl -MCPAN -e shell install Apache::Wyrd
For more information on module installation, please visit the detailed CPAN module installation guide.