|
Apache::Wyrd::Datum - Abstract data-checking objects for Wyrd Input objects |
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.
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:
And will probably want to override:
All Datum objects are initialized with
Barry King <wyrd@nospam.wyrdwright.com>
Copyright 2002-2004 Wyrdwright, Inc. and licensed under the GNU GPL.
See LICENSE under the documentation for Apache::Wyrd.
1;
|
Apache::Wyrd::Datum - Abstract data-checking objects for Wyrd Input objects |