Stefan Hornburg (Racke) > Data-Transpose-0.0007 > Data::Transpose::Validator::Base

Download:
Data-Transpose-0.0007.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source   Latest Release: Data-Transpose-0.0010

NAME ^

Data::Transpose::Validator::Base - Base class for Data::Transpose::Validator

SYNOPSIS ^

  my $v = Data::Transpose::Validator::Base->new;
  ok($v->is_valid("string"), "A string is valid");
  ok($v->is_valid([]), "Empty array is valid");
  ok($v->is_valid({}), "Empty hash is valid");
  ok(!$v->is_valid(undef), "undef is not valid");

METHODS (to be overwritten by the subclasses) ^

new()

Constructor. It accepts an hash with the options.

required

Set or retrieve the required option. Returns true if required, false otherwise.

dtv_options

Set or retrieve the Data::Transpose::Validator options. Given that the various classes have a different way to initialize the objects, this should be done only once the object has been built.

E.g.

   my $obj = $class->new(%classoptions);
   $obj->dtv_options(\%dtv_options);

dtv_value

On transposing, the value of the field is stored here.

reset_dtv_value

Delete the dtv_value from the object

is_valid($what)

Main method. Return true if the variable passed is defined, false if it's undefined, storing an error.

error

Main method to check why the validator returned false. When an argument is provided, set the error.

In scalar context it returns a human-readable string with the errors.

In list context it returns the raw error list, where each element is a pair of code and strings.

reset_errors

Clear the errors stored.

error_codes

Returns the list of the error codes for the current validation.

warnings

Set or retrieve a list of warnings issued by the validator.

reset_warnings

Reset the warning list.

syntax highlighting: