The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

ETLp::File::Validate - Validate file content

SYNOPSIS

    use ETLp::File::Validate;

    my $val = ETLp::File::Validate->new(
        data_directory        => '/data/incoming',
        file_config_directory => "$Bin/../conf",
        file_definition       => 'file_def.cfg',
        localize              => 1,
        type                  => 'csv'
    );
    
    my $ret = $val->validate('data.txt');
    
    unless($ret) {
        my @errors = @{$val->get_errors};
        
        foreach my $error (@errors) {
            print $error->{line_number} .": " . $error->{message}, "\n";
        }
    }
    ...

METHODS

new

Create a validation object.

Parameters

Hash or hashref consisting of

    * type: Required. The type of file (csv), fixed width
    * data_directory: Optional. The directory where the files to be
      loaded are located.
    * file_config_directory: Optional. The directory where the
      file_defintion file can be found.
    * file_definition: Required. A file that contains a defintion
      of the validation rules. If the file_config_directory parameter
      is not set, then this must be the full path to the defintion file

Returns

    * a ETLp::File::Validate object

validate

Validate the file

Parameters

    * The name of the file being validated,
    

Returns

    * Success flag (0 = fail, success = 1)

get_errors

Returns a list of error messages

Parameters

    * None
    

Returns

    * An arrayref of hashrefs. Each array elemnet is an error. Each
      hashref contains the error details
      
          o line_number: The line number where the error occurred
          o field_name: The name of the field that failed validated
          o field_value: The value in the field
          o message: The error message
    

config

Returns the parsed configuration used by the validation

Parameters

    * None
    

Returns

    * a ETLp::File::Config object

LICENSE AND COPYRIGHT

Copyright 2010 Redbone Systems Ltd

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

The terms are in the LICENSE file that accompanies this application