Sha256: afbe31e888ab8c24619e517793d79f912fcc01e6bbeddb15d9a5a82f2b2ddfed

Contents?: true

Size: 337 Bytes

Versions: 1

Compression:

Stored size: 337 Bytes

Contents

# frozen_string_literal: true

require 'active_model'

class TypeValidator
  class ByKindOf
    def self.invalid?(value, options)
      types = Array(options[:is_a] || options[:kind_of])

      return if types.any? { |type| value.is_a?(type) }

      "must be a kind of: #{types.map { |klass| klass.name }.join(', ')}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
type_validator-0.7.0 lib/type_validator/by_kind_of.rb