{
    "mode": "perldoc",
    "parameter": "Type::Tiny::Class",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AClass/json",
    "generated": "2026-10-02T17:33:48Z",
    "synopsis": "Using via Types::Standard:\npackage Local::Horse {\nuse Moo;\nuse Types::Standard qw( Str InstanceOf );\nhas name => (\nis       => 'ro',\nisa      => Str,\n);\nhas owner => (\nis       => 'ro',\nisa      => InstanceOf[ 'Local::Person' ],\ndefault  => sub { Local::Person->new },\n);\n}\nUsing Type::Tiny::Class's export feature:\npackage Local::Horse {\nuse Moo;\nuse Types::Standard qw( Str );\nuse Type::Tiny::Class 'Local::Person';\nhas name => (\nis       => 'ro',\nisa      => Str,\n);\nhas owner => (\nis       => 'ro',\nisa      => LocalPerson,\ndefault  => sub { LocalPerson->new },\n);\n}\nUsing Type::Tiny::Class's object-oriented interface:\npackage Local::Horse {\nuse Moo;\nuse Types::Standard qw( Str );\nuse Type::Tiny::Class;\nmy $Person = Type::Tiny::Class->new( class => 'Local::Person' );\nhas name => (\nis       => 'ro',\nisa      => Str,\n);\nhas owner => (\nis       => 'ro',\nisa      => $Person,\ndefault  => sub { $Person->new },\n);\n}\nUsing Type::Utils's functional interface:\npackage Local::Horse {\nuse Moo;\nuse Types::Standard qw( Str );\nuse Type::Utils;\nmy $Person = classtype 'Local::Person';\nhas name => (\nis       => 'ro',\nisa      => Str,\n);\nhas owner => (\nis       => 'ro',\nisa      => $Person,\ndefault  => sub { $Person->new },\n);\n}",
    "sections": {
        "NAME": {
            "content": "Type::Tiny::Class - type constraints based on the \"isa\" method\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "Using via Types::Standard:\n\npackage Local::Horse {\nuse Moo;\nuse Types::Standard qw( Str InstanceOf );\n\nhas name => (\nis       => 'ro',\nisa      => Str,\n);\n\nhas owner => (\nis       => 'ro',\nisa      => InstanceOf[ 'Local::Person' ],\ndefault  => sub { Local::Person->new },\n);\n}\n\nUsing Type::Tiny::Class's export feature:\n\npackage Local::Horse {\nuse Moo;\nuse Types::Standard qw( Str );\nuse Type::Tiny::Class 'Local::Person';\n\nhas name => (\nis       => 'ro',\nisa      => Str,\n);\n\nhas owner => (\nis       => 'ro',\nisa      => LocalPerson,\ndefault  => sub { LocalPerson->new },\n);\n}\n\nUsing Type::Tiny::Class's object-oriented interface:\n\npackage Local::Horse {\nuse Moo;\nuse Types::Standard qw( Str );\nuse Type::Tiny::Class;\n\nmy $Person = Type::Tiny::Class->new( class => 'Local::Person' );\n\nhas name => (\nis       => 'ro',\nisa      => Str,\n);\n\nhas owner => (\nis       => 'ro',\nisa      => $Person,\ndefault  => sub { $Person->new },\n);\n}\n\nUsing Type::Utils's functional interface:\n\npackage Local::Horse {\nuse Moo;\nuse Types::Standard qw( Str );\nuse Type::Utils;\n\nmy $Person = classtype 'Local::Person';\n\nhas name => (\nis       => 'ro',\nisa      => Str,\n);\n\nhas owner => (\nis       => 'ro',\nisa      => $Person,\ndefault  => sub { $Person->new },\n);\n}\n",
            "subsections": []
        },
        "STATUS": {
            "content": "This module is covered by the Type-Tiny stability policy.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Type constraints of the general form \"{ $->isa(\"Some::Class\") }\".\n\nThis package inherits from Type::Tiny; see that for most documentation. Major differences are\nlisted below:\n",
            "subsections": [
                {
                    "name": "Constructor",
                    "content": "\"new\"\nWhen the constructor is called on an *instance* of Type::Tiny::Class, it passes the call\nthrough to the constructor of the class for the constraint. So for example:\n\nmy $type = Type::Tiny::Class->new(class => \"Foo::Bar\");\nmy $obj  = $type->new(hello => \"World\");\nsay ref($obj);   # prints \"Foo::Bar\"\n\nThis little bit of DWIM was borrowed from MooseX::Types::TypeDecorator, but Type::Tiny\ndoesn't take the idea quite as far.\n"
                },
                {
                    "name": "Attributes",
                    "content": "\"class\"\nThe class for the constraint.\n\n\"constraint\"\nUnlike Type::Tiny, you *cannot* pass a constraint coderef to the constructor. Instead rely\non the default.\n\n\"inlined\"\nUnlike Type::Tiny, you *cannot* pass an inlining coderef to the constructor. Instead rely on\nthe default.\n\n\"parent\"\nParent is automatically calculated, and cannot be passed to the constructor.\n"
                },
                {
                    "name": "Methods",
                    "content": "\"plusconstructors($source, $methodname)\"\nMuch like \"pluscoercions\" but adds coercions that go via a constructor. (In fact, this is\nimplemented as a wrapper for \"pluscoercions\".)\n\nExample:\n\npackage MyApp::Minion;\n\nuse Moose; extends \"MyApp::Person\";\n\nuse Types::Standard qw( HashRef Str );\nuse Type::Utils qw( classtype );\n\nmy $Person = classtype({ class => \"MyApp::Person\" });\n\nhas boss => (\nis     => \"ro\",\nisa    => $Person->plusconstructors(\nHashRef,     \"new\",\nStr,         \"newfromname\",\n),\ncoerce => 1,\n);\n\npackage main;\n\nMyApp::Minion->new(\n...,\nboss => \"Bob\",  ## via MyApp::Person->newfromname\n);\n\nMyApp::Minion->new(\n...,\nboss => { name => \"Bob\" },  ## via MyApp::Person->new\n);\n\nBecause coercing \"HashRef\" via constructor is a common desire, if you call\n\"plusconstructors\" with no arguments at all, this is the default.\n\n$classtype->plusconstructors(HashRef, \"new\")\n$classtype->plusconstructors()  ## identical to above\n\nThis is handy for Moose/Mouse/Moo-based classes.\n"
                },
                {
                    "name": "stringifies_to",
                    "content": "See Type::Tiny::ConstrainedObject.\n"
                },
                {
                    "name": "numifies_to",
                    "content": "See Type::Tiny::ConstrainedObject.\n\n\"withattributevalues($attr1 => $constraint1, ...)\"\nSee Type::Tiny::ConstrainedObject.\n"
                },
                {
                    "name": "Exports",
                    "content": "Type::Tiny::Class can be used as an exporter.\n\nuse Type::Tiny::Class 'HTTP::Tiny';\n\nThis will export the following functions into your namespace:\n\n\"HTTPTiny\""
                },
                {
                    "name": "is_HTTPTiny",
                    "content": ""
                },
                {
                    "name": "assert_HTTPTiny",
                    "content": ""
                },
                {
                    "name": "to_HTTPTiny",
                    "content": "You will also be able to use \"HTTPTiny->new(...)\" as a shortcut for \"HTTP::Tiny->new(...)\".\n\nMultiple types can be exported at once:\n\nuse Type::Tiny::Class qw( HTTP::Tiny LWP::UserAgent );\n"
                }
            ]
        },
        "BUGS": {
            "content": "Please report any bugs to <https://github.com/tobyink/p5-type-tiny/issues>.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Type::Tiny::Manual.\n\nType::Tiny.\n\nMoose::Meta::TypeConstraint::Class.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Toby Inkster <tobyink@cpan.org>.\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENCE": {
            "content": "This software is copyright (c) 2013-2014, 2017-2023 by Toby Inkster.\n\nThis is free software; you can redistribute it and/or modify it under the same terms as the Perl\n5 programming language system itself.\n",
            "subsections": []
        },
        "DISCLAIMER OF WARRANTIES": {
            "content": "THIS PACKAGE IS PROVIDED \"AS IS\" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\nWITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.\n",
            "subsections": []
        }
    },
    "summary": "Type::Tiny::Class - type constraints based on the \"isa\" method",
    "flags": [],
    "examples": [],
    "see_also": []
}