NAME

MooX::Types::MooseLike - some Moosish types and a type builder

SYNOPSIS

  package MyApp::Types;
  use MooX::Types::MooseLike::Base;
  use base qw(Exporter);
  our @EXPORT_OK = ();

  # Define some types
  my $defs = [{
    name => 'MyType',
    test => sub { predicate($_[0]) },
    message => sub { "$_[0] is not the type we want!" }
  },
  {
    name => 'MyLengthTypeWithParam',
    test => sub {
      my ($value, $param) = @_;
      length($value) < $param;
    },
    message => sub { "$_[0] is too large! It should be less than $_[1]." }
  }
];

  # Make the types available - this adds them to @EXPORT_OK automatically.
  MooX::Types::MooseLike::register_types($defs, __PACKAGE__);

  ...

  # Somewhere in code that uses the type
  package MyApp::Foo;
  use Moo;
  use MyApp::Types qw(MyType);
  has attribute => (
    is  => 'ro',
    isa => MyType,
  );

  has string => (
    is  => 'ro',
    isa => MyLengthTypeWithParam(25)
  );

DESCRIPTION

See MooX::Types::MooseLike::Base for an example of how to build base types.

See MooX::Types::MooseLike::Numeric for an example of how to build subtypes.

See MooX::Types::SetObject for an example of how to build parameterized types.

AUTHOR

mateu - Mateu X. Hunter (cpan:MATEU) <hunter@missoula.org>

CONTRIBUTORS

mst - Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk>

Mithaldu - Christian Walde (cpan:MITHALDU) <walde.christian@googlemail.com>

Matt Phillips (cpan:MATTP) <mattp@cpan.org>

Arthur Axel fREW Schmidt (cpan:FREW) <frioux@gmail.com>

COPYRIGHT

Copyright (c) 2011-2012 the MooX::Types::MooseLike "AUTHOR" and "CONTRIBUTORS" as listed above.

LICENSE

This library is free software and may be distributed under the same terms as perl itself.