Build Status

NAME

Smart::Args::TypeTiny - We are smart, smart for you

SYNOPSIS

use Smart::Args::TypeTiny;

sub func2 {
    args my $p => 'Int',
         my $q => {isa => 'Int', optional => 1},
         ;
}
func2(p => 3, q => 4); # p => 3, q => 4
func2(p => 3);         # p => 3, q => undef

sub func3 {
    args my $p => {isa => 'Int', default => 3};
}
func3(p => 4); # p => 4
func3();       # p => 3

package F;
use Moo;
use Smart::Args::TypeTiny;
use Types::Standard -all;

sub method {
    args my $self,
         my $p => Int,
         ;
}
sub class_method {
    args my $class => ClassName,
         my $p     => Int,
         ;
}

sub simple_method {
    args_pos my $self, my $p;
}

my $f = F->new();
$f->method(p => 3);

F->class_method(p => 3);

F->simple_method(3);

DESCRIPTION

Smart::Args::TypeTiny provides Smart::Args-like argument validator using Type::Tiny.

IMCOMPATIBLE CHANGES WITH Smart::Args

FUNCTIONS

TIPS

SKIP TYPE CHECK

For optimization calling subroutine in runtime type check, you can overwrite check_rule like following code:

{
    no warnings 'redefine';
    *Smart::Args::TypeTiny::check_rule = \&Smart::Args::TypeTiny::Check::no_check_rule;
}

Smart::Args::TypeTiny::Check::no_check_rule is a function without type checking and type coerce, but settings such as default and optional work the same as check_rule.

SEE ALSO

Smart::Args, Data::Validator, Params::Validate, Params::ValidationCompiler

Type::Tiny, Types::Standard, Mouse::Util::TypeConstraints

LICENSE

Copyright (C) Takumi Akiyama.

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

AUTHOR

Takumi Akiyama t.akiym@gmail.com