CPAN::Packager::Config::Validator - validates configration


CPAN-Packager documentation Contained in the CPAN-Packager distribution.

Index


Code Index:

NAME

Top

CPAN::Packager::Config::Validator - validates configration

SYNOPSIS

Top

DESCRIPTION

Top

AUTHOR

Top

Takatoshi Kitano <kitano.tk@gmail.com>

SEE ALSO

Top

LICENSE

Top

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


CPAN-Packager documentation Contained in the CPAN-Packager distribution.

package CPAN::Packager::Config::Validator;
use strict;
use warnings;
use CPAN::Packager::Config::Schema;
use Kwalify;
use Log::Log4perl qw(:easy);

sub validate {
    my ( $class, $config ) = @_;
    my $schema = CPAN::Packager::Config::Schema->schema();
    $class->_validate_config( $config, $schema );
}

sub _validate_config {
    my ( $class, $config, $schema ) = @_;
    if ($schema) {
        my $res = Kwalify::validate( $schema, $config );
        unless ( $res == 1 ) {
            die "config.yaml validation error : $res";
        }
    }
    else {
        WARN("Kwalify is not installed. Skipping the config validation.");
    }
}

1;

__END__