dry-types

v1.8 v1.7
  1. Introduction
  2. Getting Started
  3. Built-in Types
  4. Type Attributes
  5. Default Values
  6. Fallbacks
  7. Constraints
  8. Hash Schemas
  9. Array With Member
  10. Enum
  11. Map
  12. Combining Types
    1. Intersection
    2. Sum
  13. Custom Types
  14. Custom Type Builders
  15. Extensions
    1. Maybe
    2. Monads

TOC


Map

Map describes a homogeneous hashmap. This means only types of keys and values are known. You can simply imagine a map input as a list of key-value pairs.

int_float_hash = Types::Hash.map(Types::Integer, Types::Float)
int_float_hash[100 => 300.0, 42 => 70.0]
# => {100=>300.0, 42=>70.0}

# Only accepts mappings of integers to floats
int_float_hash[name: 'Jane']
# => Dry::Types::MapError: input key :name is invalid: type?(Integer, :name)