From: Christian Hansen Date: Mon, 17 Apr 2006 15:30:26 +0000 (+0000) Subject: required does not throw an error if it has a default value X-Git-Tag: 0_05~27 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6730c8d9ccb58aba02c57b028c7ff918b31dcbf7;p=gitmo%2FMoose.git required does not throw an error if it has a default value --- diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index 8ec469f..e41d199 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -58,9 +58,9 @@ sub construct_instance { else { # skip it if it's lazy next if $attr->is_lazy; - # and die if it is required + # and die if it's required and doesn't have a default value confess "Attribute (" . $attr->name . ") is required" - if $attr->is_required + if $attr->is_required && !$attr->has_default; } # if nothing was in the %params, we can use the # attribute's default value (if it has one)