Sha256: 83a007b231c613ef09f9c7d5288bb6ad98ccc9f1a7d86ddee2513c5d5db5dadb
Contents?: true
Size: 549 Bytes
Versions: 14
Compression:
Stored size: 549 Bytes
Contents
module ChefAPI class Validator::Type < Validator::Base attr_reader :types # # Overload the super method to capture the type attribute in the options # hash. # def initialize(attribute, type) super @types = Array(type) end def validate(resource) value = resource._attributes[attribute] if value && !types.any? { |type| value.is_a?(type) } short_name = type.to_s.split('::').last resource.errors.add(attribute, "must be a kind of #{short_name}") end end end end
Version data entries
14 entries across 14 versions & 2 rubygems