logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Env::Assert - Ensure that the environment variables match what you need, or abort.

Author

       Mikko Koivunalho <mikkoi@cpan.org>

Dependencies

       No external dependencies outside Perl's standard distribution.

Functions

       No functions are automatically exported to the calling namespace.

   assert(\%env,\%want,\%params)
       Ensure your environment, parameter env (hashref), matches with the environment description, parameter
       want (hashref).  Use parameter params (hashref) to specify processing options.

       Supported params:

       break_at_first_error
               Verify environment only up until the first error.  Then break and return with only that error.

       Return: hashref: { success => 1/0, errors => hashref, };

   report_errors(\%errors)
       Report errors in a nicely formatted way.

   file_to_desc(@rows)
       Extract an environment description from a .envdesc file.

Name

       Env::Assert - Ensure that the environment variables match what you need, or abort.

Notes

Status

       Package Env::Assert is currently being developed so changes in the API are possible, though not likely.

Synopsis

           use Env::Assert qw( assert report_errors );

           my %want = (
               options => {
                   exact => 1,
               },
               variables => {
                   USER => { regexp => '^[[:word:]]{1}$', required => 1 },
               },
           );
           my %parameters;
           $parameters{'break_at_first_error'} = 1;
           my $r = assert( \%ENV, \%want, \%parameters );
           if( ! $r->{'success'} ) {
               print report_errors( $r->{'errors'} );
           }

Version

       version 0.010

See Also