Sha256: 5a6f00354cb47f5d55316420ac43c4686038d870232cc36b4c946fc025195f4e
Contents?: true
Size: 1.56 KB
Versions: 26
Compression:
Stored size: 1.56 KB
Contents
module Foobara module BuiltinTypes module Duck module SupportedValidators class InstanceOf < TypeDeclarations::Validator module TypeDeclarationExtension module ExtendRegisteredTypeDeclaration module TypeDeclarationValidators class IsValidClass < TypeDeclarations::TypeDeclarationValidator class InvalidInstanceOfValueGivenError < Value::DataError class << self def message "instance_of: should be a class or the name of an existing class" end end end def applicable?(strict_type_declaration) strict_type_declaration.is_a?(Hash) && strict_type_declaration.key?(:instance_of) end def validation_errors(strict_type_declaration) instance_of = strict_type_declaration[:instance_of] return if instance_of.is_a?(::Class) if instance_of.is_a?(::String) || instance_of.is_a?(::Symbol) unless Object.const_defined?(instance_of) build_error(context: { attribute_name: :instance_of, value: instance_of }) end else build_error(context: { attribute_name: :instance_of, value: instance_of }) end end end end end end end end end end end
Version data entries
26 entries across 26 versions & 1 rubygems