{
    "mode": "perldoc",
    "parameter": "MooseX::StrictConstructor",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/MooseX%3A%3AStrictConstructor/json",
    "generated": "2026-06-16T10:13:16Z",
    "synopsis": "package My::Class;\nuse Moose;\nuse MooseX::StrictConstructor;\nhas 'size' => ( is => 'ro' );\n# then later ...\n# this blows up because color is not a known attribute\nMy::Class->new( size => 5, color => 'blue' );",
    "sections": {
        "NAME": {
            "content": "MooseX::StrictConstructor - Make your object constructors blow up on unknown attributes\n",
            "subsections": []
        },
        "VERSION": {
            "content": "version 0.21\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "package My::Class;\n\nuse Moose;\nuse MooseX::StrictConstructor;\n\nhas 'size' => ( is => 'ro' );\n\n# then later ...\n\n# this blows up because color is not a known attribute\nMy::Class->new( size => 5, color => 'blue' );\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Simply loading this module makes your constructors \"strict\". If your constructor is called with\nan attribute init argument that your class does not declare, then it calls\n\"Moose->throwerror()\". This is a great way to catch small typos.\n",
            "subsections": [
                {
                    "name": "Subverting Strictness",
                    "content": "You may find yourself wanting to have your constructor accept a parameter which does not\ncorrespond to an attribute.\n\nIn that case, you'll probably also be writing a \"BUILD()\" or \"BUILDARGS()\" method to deal with\nthat parameter. In a \"BUILDARGS()\" method, you can simply make sure that this parameter is not\nincluded in the hash reference you return. Otherwise, in a \"BUILD()\" method, you can delete it\nfrom the hash reference of parameters.\n\nsub BUILD {\nmy $self   = shift;\nmy $params = shift;\n\nif ( delete $params->{dosomething} ) {\n...\n}\n}\n"
                }
            ]
        },
        "BUGS": {
            "content": "Please report any bugs or feature requests to \"bug-moosex-strictconstructor@rt.cpan.org\", or\nthrough the web interface at <http://rt.cpan.org>. I will be notified, and then you'll\nautomatically be notified of progress on your bug as I make changes.\n\nBugs may be submitted at <https://github.com/moose/MooseX-StrictConstructor/issues>.\n\nI am also usually active on IRC as 'autarch' on \"irc://irc.perl.org\".\n",
            "subsections": []
        },
        "SOURCE": {
            "content": "The source code repository for MooseX-StrictConstructor can be found at\n<https://github.com/moose/MooseX-StrictConstructor>.\n",
            "subsections": []
        },
        "DONATIONS": {
            "content": "If you'd like to thank me for the work I've done on this module, please consider making a\n\"donation\" to me via PayPal. I spend a lot of free time creating free software, and would\nappreciate any support you'd care to offer.\n\nPlease note that I am not suggesting that you must do this in order for me to continue working\non this particular software. I will continue to do so, inasmuch as I have in the past, for as\nlong as it interests me.\n\nSimilarly, a donation made in this way will probably not make me work on this software much\nmore, unless I get so many donations that I can consider working on free software full time\n(let's all have a chuckle at that together).\n\nTo donate, log into PayPal and send money to autarch@urth.org, or use the button at\n<http://www.urth.org/~autarch/fs-donation.html>.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Dave Rolsky <autarch@urth.org>\n",
            "subsections": []
        },
        "CONTRIBUTORS": {
            "content": "*   Jesse Luehrs <doy@tozt.net>\n\n*   Karen Etheridge <ether@cpan.org>\n\n*   Ricardo Signes <rjbs@cpan.org>\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "This software is Copyright (c) 2007 - 2017 by Dave Rolsky.\n\nThis is free software, licensed under:\n\nThe Artistic License 2.0 (GPL Compatible)\n\nThe full text of the license can be found in the LICENSE file included with this distribution.\n",
            "subsections": []
        }
    },
    "summary": "MooseX::StrictConstructor - Make your object constructors blow up on unknown attributes",
    "flags": [],
    "examples": [],
    "see_also": []
}