diff options
Diffstat (limited to 'lib/chef/property.rb')
-rw-r--r-- | lib/chef/property.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/chef/property.rb b/lib/chef/property.rb index c1207d9132..e97d8f9607 100644 --- a/lib/chef/property.rb +++ b/lib/chef/property.rb @@ -479,6 +479,8 @@ class Chef # A type accepts nil explicitly if "is" allows nil, it validates as nil, *and* is not simply # an empty type. # + # A type is presumed to accept nil if it does coercion (which must handle nil). + # # These examples accept nil explicitly: # ```ruby # property :a, [ String, nil ] @@ -510,7 +512,8 @@ class Chef # # @api private def explicitly_accepts_nil?(resource) - options.has_key?(:is) && resource.send(:_pv_is, { name => nil }, name, options[:is], raise_error: false) + options.has_key?(:coerce) || + (options.has_key?(:is) && resource.send(:_pv_is, { name => nil }, name, options[:is], raise_error: false)) end def get_value(resource) |