Sha256: f12a6af09fb2c2a700c86fac986bed5612d1f9eb81a0919694d1a58ae53e91f6

Contents?: true

Size: 1.82 KB

Versions: 26

Compression:

Stored size: 1.82 KB

Contents

module Foobara
  module BuiltinTypes
    module Tuple
      module SupportedProcessors
        class ElementTypeDeclarations < TypeDeclarations::ElementProcessor
          module TypeDeclarationExtension
            module ExtendTupleTypeDeclaration
              module TypeDeclarationValidators
                class SizeMatches < TypeDeclarations::TypeDeclarationValidator
                  class IncorrectSizeError < Value::DataError
                    class << self
                      def context_type_declaration
                        {
                          expected_size: :integer,
                          actual_size: :integer,
                          value: :array
                        }
                      end
                    end
                  end

                  def applicable?(strict_type_declaration)
                    strict_type_declaration.key?(:size)
                  end

                  def validation_errors(strict_type_declaration)
                    size = strict_type_declaration[:size]
                    element_type_declarations = strict_type_declaration[:element_type_declarations]
                    element_type_declarations_size = element_type_declarations.size

                    if size != element_type_declarations_size
                      build_error(
                        message: "Expected tuple to have #{size} elements but it had #{element_type_declarations_size}",
                        context: {
                          expected_size: size,
                          actual_size: element_type_declarations_size,
                          value: strict_type_declaration
                        }
                      )
                    end
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
foobara-0.0.26 projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb
foobara-0.0.25 projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb
foobara-0.0.24 projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb
foobara-0.0.23 projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb
foobara-0.0.22 projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb
foobara-0.0.21 projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb
foobara-0.0.20 projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb
foobara-0.0.19 projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb
foobara-0.0.18 projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb
foobara-0.0.17 projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb
foobara-0.0.16 projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb
foobara-0.0.15 projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb
foobara-0.0.14 projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb
foobara-0.0.13 projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb
foobara-0.0.12 projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb
foobara-0.0.11 projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb
foobara-0.0.10 projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb
foobara-0.0.9 projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb
foobara-0.0.8 projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb
foobara-0.0.7 projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb