SYNOPSIS

     #IFUNBUILT
     use Perinci::Sub::ValidateArgs;
     #END IFUNBUILT
    
     our %SPEC;
     $SPEC{foo} = {
         v => 1.1,
         args => {
             a1 => {
                schema => 'int*',
                req => 1,
             },
             a2 => {
                 schema => [array => of=>'int*'],
                 default => 'peach',
             },
         },
     };
     sub foo {
         my %args = @_;
         # IFUNBUILT
         if (my $err = validate_args(\%args)) { return $err }
         # END IFUNBUILT
    
         ...
     }

DESCRIPTION

    This is an experimental module to ease validating function arguments
    for unwrapped function.

FUNCTIONS

    All the functions are exported by default.

 validate_args(\%args) => $err

    Get Rinci function metadata from caller's %SPEC package variable. Then
    create (and cache) a set of Data::Sah validator to check the value of
    each argument. If there is an error, will return an error response
    $err. Otherwise will return undef.

    Arguments in %args will have their default values/coercions/filters
    applied, so they are ready for use.

    Currently only support args_as => 'hash' (the default).

SEE ALSO

    Rinci, Data::Sah

    Dist::Zilla::Plugin::IfBuilt

