Attribute-Params-Validate

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

      }
    
      # takes positional params
      # first two are mandatory, third is optional
      sub bar : ValidatePos( 1, 1, 0 )
      {
          # insert code here
      }
    
      # for some reason Perl insists that the entire attribute be on one line
      sub foo2 : Validate( foo => { type => ARRAYREF }, bar => { can => [ 'print', 'flush', 'frobnicate' ] }, baz => { type => SCALAR, callbacks => { 'numbers only' => sub { shift() =~ /^\d+$/ }, 'less than 90' => sub { shift() < 90 } } } )
      {
          # insert code here
      }
    
      # note that this is marked as a method.  This is very important!
      sub baz : Validate( foo => { type => ARRAYREF }, bar => { isa => 'Frobnicator' } ) method
      {
          # insert code here
      }

lib/Attribute/Params/Validate.pm  view on Meta::CPAN

  }

  # takes positional params
  # first two are mandatory, third is optional
  sub bar : ValidatePos( 1, 1, 0 )
  {
      # insert code here
  }

  # for some reason Perl insists that the entire attribute be on one line
  sub foo2 : Validate( foo => { type => ARRAYREF }, bar => { can => [ 'print', 'flush', 'frobnicate' ] }, baz => { type => SCALAR, callbacks => { 'numbers only' => sub { shift() =~ /^\d+$/ }, 'less than 90' => sub { shift() < 90 } } } )
  {
      # insert code here
  }

  # note that this is marked as a method.  This is very important!
  sub baz : Validate( foo => { type => ARRAYREF }, bar => { isa => 'Frobnicator' } ) method
  {
      # insert code here
  }

t/basic.t  view on Meta::CPAN

    return $data{c};
}

sub bar : Validate( c => { type => SCALAR } ) method {
    my $self = shift;
    my %data = @_;
    return $data{c};
}

sub baz :
    Validate( foo => { type => ARRAYREF, callbacks => { '5 elements' => sub { @{shift()} == 5 } } } )
{
    my %data = @_;
    return $data{foo}->[0];
}

sub buz : ValidatePos( 1 ) {
    return $_[0];
}

sub quux : ValidatePos( { type => SCALAR }, 1 ) {



( run in 0.787 second using v1.01-cache-2.11-cpan-9b1e4054eb1 )