So, Type::Tiny 1.2.0 (a.k.a. 1.002000 using Perlish decimals) is now available on CPAN.

Highlights since 1.0.0:

  • Type::Params now has compile_named and validate_named.

    This allows for:

    sub add_pet {
      state $check = compile_named(
        name    => Str,
        species => Str,
        age     => Optional[Int],
      );
      my $args = $check->(@_);
    
      ...; # do stuff with $args hashref
    }

    It's faster than the old compile slurpy Dict hack.

  • Type::Tiny's constraint parameter may be a string of code.

    isa => Int->where('$_ % 2 == 0')  # even numbers only
  • Types::Standard::CycleTuple added.

    my $type = CycleTuple[Str, ArrayRef, Int];
    $type->assert_valid( [ "foo", [], 42, "bar", [], 21 ] );  # ok
    $type->assert_valid( [ "foo", [], 42, "bar", [], 2.1 ] ); # throws exception
  • Types::Standard::RegexpRef now accepts blessed objects where $object->isa('Regexp'). This plays better with re::engine::* pragmas.

  • Fixed bug where Types::Standard::Int would sometimes accept an overloaded object. (It never should.)

  • Various performance enhancements and bug fixes.