Data::Validator::Item

Data::Validator::Item is a Factory Class to validate data items.
Download

Data::Validator::Item Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Anthony Staines
  • Publisher web site:
  • http://search.cpan.org/~astaines/Data-Validator-Item-0.75/Item.pm

Data::Validator::Item Tags


Data::Validator::Item Description

Data::Validator::Item is a Factory Class to validate data items. Data::Validator::Item is a Factory Class to validate data items.This is an attempt to create an object which will permit semi-automatic verification of a data value.SYNOPSIS use Data::Validator::Item; my $item = Data::Validator::Item->new(); #Create a new Data::Validator::Item, called $item. #Set values $item->name('fred'); $item->values(); or $item->values(@array); $item->missing('*'); or $item->missing(''); #undef is unlikely to be sensible! $item->min(0); $item->max(100); $item->verify($reference_to_subroutine); #Used in the $item->validate() function $item->transform($reference_to_subroutine); #Used in the $item->put() function #Get values my $name = $item->name(); my @values = $item->values(); my $missing = $item->missing(); etc...#Use it.. $item->validate(); #Returns 1 for success, 0 for failure $item->error(); #Returns the correct error message $item->put();USAGEMany people work with data organised as records, each containing (potentially many) variables. It is often necessary to process files of such records, and to test every variable within every record to ensure that each one is valid. I do this before putting data from very large flat files into my databases. For each variable I had a need to define specific, sometimes complex rules for validity, then implement them, and check them. This is what Data::Validator::Item is for.Note carefully that Data::Validator::Item handles only one scalar vlaue at a time. This value could come from a file, a database, an array, a hash or your granny's parrot. Data::Validator::Item doesn't care.I use Data::Validator::Item as follows. I create one for every named variable in my data file. In many real applications most of this setup can be done by looping over a list of variable names, creating many Data::Validator::Items each named for the corresponding variable. Common features, like missing values, and names can be set in this loop.Specifics, like values(), min(), max(), verify() and so on can be set individually. I then create a hash to hold all of the Data::Validator::Items for a particular data source, The keys of this hash are the names of the variables, and the values are the Data:Validators themselves. Y.M.M.V. Requirements: · Perl


Data::Validator::Item Related Software