{
    "content": [
        {
            "type": "text",
            "text": "# Type::Tiny::Enum (perldoc)\n\n## NAME\n\nType::Tiny::Enum - string enum type constraints\n\n## SYNOPSIS\n\nUsing via Types::Standard:\npackage Horse {\nuse Moo;\nuse Types::Standard qw( Str Enum );\nhas name    => ( is => 'ro', isa => Str );\nhas status  => ( is => 'ro', isa => Enum[ 'alive', 'dead' ] );\nsub neigh {\nmy ( $self ) = @;\nreturn if $self->status eq 'dead';\n...;\n}\n}\nUsing Type::Tiny::Enum's export feature:\npackage Horse {\nuse Moo;\nuse Types::Standard qw( Str );\nuse Type::Tiny::Enum Status => [ 'alive', 'dead' ];\nhas name    => ( is => 'ro', isa => Str );\nhas status  => ( is => 'ro', isa => Status, default => STATUSALIVE );\nsub neigh {\nmy ( $self ) = @;\nreturn if $self->status eq STATUSDEAD;\n...;\n}\n}\nUsing Type::Tiny::Enum's object-oriented interface:\npackage Horse {\nuse Moo;\nuse Types::Standard qw( Str );\nuse Type::Tiny::Enum;\nmy $Status = Type::Tiny::Enum->new(\nname   => 'Status',\nvalues => [ 'alive', 'dead' ],\n);\nhas name    => ( is => 'ro', isa => Str );\nhas status  => ( is => 'ro', isa => $Status, default => $Status->[0] );\nsub neigh {\nmy ( $self ) = @;\nreturn if $self->status eq $Status->[0];\n...;\n}\n}\n\n## DESCRIPTION\n\nEnum type constraints.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **STATUS**\n- **DESCRIPTION** (8 subsections)\n- **BUGS**\n- **SEE ALSO**\n- **AUTHOR**\n- **COPYRIGHT AND LICENCE**\n- **DISCLAIMER OF WARRANTIES**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Type::Tiny::Enum",
        "section": "",
        "mode": "perldoc",
        "summary": "Type::Tiny::Enum - string enum type constraints",
        "synopsis": "Using via Types::Standard:\npackage Horse {\nuse Moo;\nuse Types::Standard qw( Str Enum );\nhas name    => ( is => 'ro', isa => Str );\nhas status  => ( is => 'ro', isa => Enum[ 'alive', 'dead' ] );\nsub neigh {\nmy ( $self ) = @;\nreturn if $self->status eq 'dead';\n...;\n}\n}\nUsing Type::Tiny::Enum's export feature:\npackage Horse {\nuse Moo;\nuse Types::Standard qw( Str );\nuse Type::Tiny::Enum Status => [ 'alive', 'dead' ];\nhas name    => ( is => 'ro', isa => Str );\nhas status  => ( is => 'ro', isa => Status, default => STATUSALIVE );\nsub neigh {\nmy ( $self ) = @;\nreturn if $self->status eq STATUSDEAD;\n...;\n}\n}\nUsing Type::Tiny::Enum's object-oriented interface:\npackage Horse {\nuse Moo;\nuse Types::Standard qw( Str );\nuse Type::Tiny::Enum;\nmy $Status = Type::Tiny::Enum->new(\nname   => 'Status',\nvalues => [ 'alive', 'dead' ],\n);\nhas name    => ( is => 'ro', isa => Str );\nhas status  => ( is => 'ro', isa => $Status, default => $Status->[0] );\nsub neigh {\nmy ( $self ) = @;\nreturn if $self->status eq $Status->[0];\n...;\n}\n}",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 55,
                "subsections": []
            },
            {
                "name": "STATUS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 5,
                "subsections": [
                    {
                        "name": "Constructors",
                        "lines": 9
                    },
                    {
                        "name": "Attributes",
                        "lines": 23
                    },
                    {
                        "name": "Methods",
                        "lines": 46
                    },
                    {
                        "name": "Exports",
                        "lines": 7
                    },
                    {
                        "name": "is_Status",
                        "lines": 1
                    },
                    {
                        "name": "assert_Status",
                        "lines": 1
                    },
                    {
                        "name": "to_Status",
                        "lines": 10
                    },
                    {
                        "name": "Overloading",
                        "lines": 2
                    }
                ]
            },
            {
                "name": "BUGS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENCE",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "DISCLAIMER OF WARRANTIES",
                "lines": 4,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Type::Tiny::Enum - string enum type constraints\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "Using via Types::Standard:\n\npackage Horse {\nuse Moo;\nuse Types::Standard qw( Str Enum );\n\nhas name    => ( is => 'ro', isa => Str );\nhas status  => ( is => 'ro', isa => Enum[ 'alive', 'dead' ] );\n\nsub neigh {\nmy ( $self ) = @;\nreturn if $self->status eq 'dead';\n...;\n}\n}\n\nUsing Type::Tiny::Enum's export feature:\n\npackage Horse {\nuse Moo;\nuse Types::Standard qw( Str );\nuse Type::Tiny::Enum Status => [ 'alive', 'dead' ];\n\nhas name    => ( is => 'ro', isa => Str );\nhas status  => ( is => 'ro', isa => Status, default => STATUSALIVE );\n\nsub neigh {\nmy ( $self ) = @;\nreturn if $self->status eq STATUSDEAD;\n...;\n}\n}\n\nUsing Type::Tiny::Enum's object-oriented interface:\n\npackage Horse {\nuse Moo;\nuse Types::Standard qw( Str );\nuse Type::Tiny::Enum;\n\nmy $Status = Type::Tiny::Enum->new(\nname   => 'Status',\nvalues => [ 'alive', 'dead' ],\n);\n\nhas name    => ( is => 'ro', isa => Str );\nhas status  => ( is => 'ro', isa => $Status, default => $Status->[0] );\n\nsub neigh {\nmy ( $self ) = @;\nreturn if $self->status eq $Status->[0];\n...;\n}\n}\n",
                "subsections": []
            },
            "STATUS": {
                "content": "This module is covered by the Type-Tiny stability policy.\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Enum type constraints.\n\nThis package inherits from Type::Tiny; see that for most documentation. Major differences are\nlisted below:\n",
                "subsections": [
                    {
                        "name": "Constructors",
                        "content": "The \"new\" constructor from Type::Tiny still works, of course. But there is also:\n\n\"newunion( typeconstraints => \\@enums, %opts )\"\nCreates a new enum type constraint which is the union of existing enum type constraints.\n\n\"newintersection( typeconstraints => \\@enums, %opts )\"\nCreates a new enum type constraint which is the intersection of existing enum type\nconstraints.\n"
                    },
                    {
                        "name": "Attributes",
                        "content": "\"values\"\nArrayref of allowable value strings. Non-string values (e.g. objects with overloading) will\nbe stringified in the constructor.\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 always Types::Standard::Str, and cannot be passed to the constructor.\n\n\"uniquevalues\"\nThe list of \"values\" but sorted and with duplicates removed. This cannot be passed to the\nconstructor.\n\n\"coercion\"\nIf \"coercion => 1\" is passed to the constructor, the type will have a coercion using the\n\"closestmatch\" method.\n"
                    },
                    {
                        "name": "Methods",
                        "content": "\"asregexp\"\nReturns the enum as a regexp which strings can be checked against. If you're checking *a\nlot* of strings, then using this regexp might be faster than checking each string against\n\nmy $enum  = Type::Tiny::Enum->new(...);\nmy $check = $enum->compiledcheck;\nmy $re    = $enum->asregexp;\n\n# fast\nmy @validtokens = grep $enum->check($), @alltokens;\n\n# faster\nmy @validtokens = grep $check->($), @alltokens;\n\n# fastest\nmy @validtokens = grep /$re/, @alltokens;\n\nYou can get a case-insensitive regexp using \"$enum->asregexp('i')\".\n\n\"closestmatch\"\nReturns the closest match in the enum for a string.\n\nmy $enum = Type::Tiny::Enum->new(\nvalues => [ qw( foo bar baz quux ) ],\n);\n\nsay $enum->closestmatch(\"FO\");   # ==> foo\n\nIt will try to find an exact match first, fall back to a case-insensitive match, if it still\ncan't find one, will try to find a head substring match, and finally, if given an integer,\nwill use that as an index.\n\nmy $enum = Type::Tiny::Enum->new(\nvalues => [ qw( foo bar baz quux ) ],\n);\n\nsay $enum->closestmatch(  0 );  # ==> foo\nsay $enum->closestmatch(  1 );  # ==> bar\nsay $enum->closestmatch(  2 );  # ==> baz\nsay $enum->closestmatch( -1 );  # ==> quux\n\n\"iswordsafe\"\nReturns true if none of the values in the enumeration contain a non-word character. Word\ncharacters include letters, numbers, and underscores, but not most punctuation or\nwhitespace.\n"
                    },
                    {
                        "name": "Exports",
                        "content": "Type::Tiny::Enum can be used as an exporter.\n\nuse Type::Tiny::Enum Status => [ 'dead', 'alive' ];\n\nThis will export the following functions into your namespace:\n\n\"Status\""
                    },
                    {
                        "name": "is_Status",
                        "content": ""
                    },
                    {
                        "name": "assert_Status",
                        "content": ""
                    },
                    {
                        "name": "to_Status",
                        "content": "\"STATUSDEAD\"\n\"STATUSALIVE\"\n\nMultiple enumerations can be exported at once:\n\nuse Type::Tiny::Enum (\nStatus    => [ 'dead', 'alive' ],\nTaxStatus => [ 'paid', 'pending' ],\n);\n"
                    },
                    {
                        "name": "Overloading",
                        "content": "*   Arrayrefification calls \"values\".\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::Enum.\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": []
            }
        }
    }
}