{
    "content": [
        {
            "type": "text",
            "text": "# Moose::Cookbook::Snack::Types (perldoc)\n\n## NAME\n\nMoose::Cookbook::Snack::Types - Snippets of code for using Types and Type Constraints\n\n## SYNOPSIS\n\npackage Point;\nuse Moose;\nhas 'x' => ( isa => 'Int', is => 'ro' );\nhas 'y' => ( isa => 'Int', is => 'rw' );\npackage main;\nuse Try::Tiny;\nmy $point = try {\nPoint->new( x => 'fifty', y => 'forty' );\n}\ncatch {\nprint \"Oops: $\";\n};\nmy $point;\nmy $xval             = 'forty-two';\nmy $xattribute       = Point->meta->findattributebyname('x');\nmy $xtypeconstraint = $xattribute->typeconstraint;\nif ( $xtypeconstraint->check($xval) ) {\n$point = Point->new( x => $xval, y => 0 );\n}\nelse {\nprint \"Value: $xval is not an \" . $xtypeconstraint->name . \"\\n\";\n}\n\n## DESCRIPTION\n\nThis is the Point example from Moose::Cookbook::Basics::PointAttributesAndSubclassing with type\nchecking added.\n\n## Sections\n\n- **NAME**\n- **VERSION**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **SEE ALSO**\n- **AUTHORS**\n- **COPYRIGHT AND LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Moose::Cookbook::Snack::Types",
        "section": "",
        "mode": "perldoc",
        "summary": "Moose::Cookbook::Snack::Types - Snippets of code for using Types and Type Constraints",
        "synopsis": "package Point;\nuse Moose;\nhas 'x' => ( isa => 'Int', is => 'ro' );\nhas 'y' => ( isa => 'Int', is => 'rw' );\npackage main;\nuse Try::Tiny;\nmy $point = try {\nPoint->new( x => 'fifty', y => 'forty' );\n}\ncatch {\nprint \"Oops: $\";\n};\nmy $point;\nmy $xval             = 'forty-two';\nmy $xattribute       = Point->meta->findattributebyname('x');\nmy $xtypeconstraint = $xattribute->typeconstraint;\nif ( $xtypeconstraint->check($xval) ) {\n$point = Point->new( x => $xval, y => 0 );\n}\nelse {\nprint \"Value: $xval is not an \" . $xtypeconstraint->name . \"\\n\";\n}",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "VERSION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 28,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 12,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 20,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Moose::Cookbook::Snack::Types - Snippets of code for using Types and Type Constraints\n",
                "subsections": []
            },
            "VERSION": {
                "content": "version 2.2200\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "package Point;\nuse Moose;\n\nhas 'x' => ( isa => 'Int', is => 'ro' );\nhas 'y' => ( isa => 'Int', is => 'rw' );\n\npackage main;\nuse Try::Tiny;\n\nmy $point = try {\nPoint->new( x => 'fifty', y => 'forty' );\n}\ncatch {\nprint \"Oops: $\";\n};\n\nmy $point;\nmy $xval             = 'forty-two';\nmy $xattribute       = Point->meta->findattributebyname('x');\nmy $xtypeconstraint = $xattribute->typeconstraint;\n\nif ( $xtypeconstraint->check($xval) ) {\n$point = Point->new( x => $xval, y => 0 );\n}\nelse {\nprint \"Value: $xval is not an \" . $xtypeconstraint->name . \"\\n\";\n}\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This is the Point example from Moose::Cookbook::Basics::PointAttributesAndSubclassing with type\nchecking added.\n\nIf we try to assign a string value to an attribute that is an \"Int\", Moose will die with an\nexplicit error message. The error will include the attribute name, as well as the type\nconstraint name and the value which failed the constraint check.\n\nWe use Try::Tiny to catch this error message.\n\nLater, we get the Moose::Meta::TypeConstraint object from a Moose::Meta::Attribute and use the\nMoose::Meta::TypeConstraint to check a value directly.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "Moose::Cookbook::Basics::PointAttributesAndSubclassing\nMoose::Util::TypeConstraints\nMoose::Meta::Attribute\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "*   Stevan Little <stevan@cpan.org>\n\n*   Dave Rolsky <autarch@urth.org>\n\n*   Jesse Luehrs <doy@cpan.org>\n\n*   Shawn M Moore <sartak@cpan.org>\n\n*   יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>\n\n*   Karen Etheridge <ether@cpan.org>\n\n*   Florian Ragwitz <rafl@debian.org>\n\n*   Hans Dieter Pearcey <hdp@cpan.org>\n\n*   Chris Prather <chris@prather.org>\n\n*   Matt S Trout <mstrout@cpan.org>\n",
                "subsections": []
            },
            "COPYRIGHT AND LICENSE": {
                "content": "This software is copyright (c) 2006 by Infinity Interactive, Inc.\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": []
            }
        }
    }
}