PGXN::Meta::Validator - Validate PGXN distribution metadata structures
my $struct = decode_json_file('META.json'); my $pmv = PGXN::Meta::Validator->new( $struct ); unless ( $pmv->is_valid ) { my $msg = "Invalid META structure. Errors found:\n"; $msg .= join( "\n", $pmv->errors ); die $msg; }
This module validates a PGXN Meta structure against the version of the the specification claimed in the meta-spec field of the structure.
meta-spec
new
my $pmv = PGXN::Meta::Validator->new( $struct )
The constructor must be passed a metadata structure.
load_file
my $meta = PGXN::Meta::Validator->load_file('META.json');
Reads in the specified JSON file and passes the resulting data structure to new(), returning the resulting PGXN::Meta::Validator object. An exception will be thrown if the file does not exist or if its contents are not valid JSON.
new()
is_valid
if ( $pmv->is_valid ) { ... }
Returns a boolean value indicating whether the metadata provided is valid.
errors
warn( join "\n", $pmv->errors );
Returns a list of errors seen during validation.
This module is stored in an open GitHub repository. Feel free to fork and contribute!
Please file bug reports via GitHub Issues or by sending mail to bug-PGXN-Meta@rt.cpan.org.
To install PGXN::Meta::Validator, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PGXN::Meta::Validator
CPAN shell
perl -MCPAN -e shell install PGXN::Meta::Validator
For more information on module installation, please visit the detailed CPAN module installation guide.