Sha256: 7d01df370823585a534bdffe64fd5a6beac93b6b3239ee6b1645ce33b8b028b7
Contents?: true
Size: 549 Bytes
Versions: 4
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
4 entries across 4 versions & 2 rubygems