Sha256: 45606f84a04c28bd1461a6501155407e475620c536c6c5b44b5a994d46862b5f

Contents?: true

Size: 1.26 KB

Versions: 27

Compression:

Stored size: 1.26 KB

Contents

module Foobara
  module BuiltinTypes
    module Attributes
      module SupportedTransformers
        class Defaults < Value::Transformer
          module TypeDeclarationExtension
            module ExtendAttributesTypeDeclaration
              module TypeDeclarationValidators
                class HashWithSymbolicKeys < TypeDeclarations::TypeDeclarationValidator
                  class InvalidDefaultValuesGivenError < Value::DataError
                    class << self
                      def message
                        "Defaults should be a hash with symbolic keys"
                      end
                    end
                  end

                  def applicable?(strict_type_declaration)
                    strict_type_declaration.is_a?(Hash) && strict_type_declaration.key?(:defaults)
                  end

                  def validation_errors(strict_type_declaration)
                    defaults = strict_type_declaration[:defaults]

                    unless defaults.is_a?(Hash) && Util.all_symbolic_keys?(defaults)
                      build_error(context: { attribute_name: :defaults, value: defaults })
                    end
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
foobara-0.0.7 projects/builtin_types/src/attributes/supported_transformers/defaults/type_declaration_extension/extend_attributes_type_declaration/type_declaration_validators/hash_with_symbolic_keys.rb
foobara-0.0.6 projects/builtin_types/src/attributes/supported_transformers/defaults/type_declaration_extension/extend_attributes_type_declaration/type_declaration_validators/hash_with_symbolic_keys.rb
foobara-0.0.5 projects/builtin_types/src/attributes/supported_transformers/defaults/type_declaration_extension/extend_attributes_type_declaration/type_declaration_validators/hash_with_symbolic_keys.rb
foobara-0.0.4 projects/builtin_types/src/attributes/supported_transformers/defaults/type_declaration_extension/extend_attributes_type_declaration/type_declaration_validators/hash_with_symbolic_keys.rb
foobara-0.0.3 projects/builtin_types/src/attributes/supported_transformers/defaults/type_declaration_extension/extend_attributes_type_declaration/type_declaration_validators/hash_with_symbolic_keys.rb
foobara-0.0.2 projects/builtin_types/src/attributes/supported_transformers/defaults/type_declaration_extension/extend_attributes_type_declaration/type_declaration_validators/hash_with_symbolic_keys.rb
foobara-0.0.1 projects/builtin_types/src/attributes/supported_transformers/defaults/type_declaration_extension/extend_attributes_type_declaration/type_declaration_validators/hash_with_symbolic_keys.rb