View Source Shapex.Types.Dict (shapex v0.2.0)

This module provides a type for validating dictionaries.

Records are a key-value pair where the key is a string and the value is any type.

Difference between a dict and a map:

  • A dict is a key-value pair where you validate that the key has the type you expect, and the value has the type you expect.
  • A map is like a struct since you define set of keys and their values that you expect.

It's better to use the Shapex.Types.dict/2 function to create a schema, since it covers implementation details and provides a more user-friendly API.

Summary

Types

@type t() :: %Shapex.Types.Dict{
  key_type: Shapex.Types.Type.t(),
  value_type: Shapex.Types.Type.t()
}