croma v0.4.2 Croma.SubtypeOfMap

Helper module to define map-based types. The following members are generated by use Croma.SubtypeOfMap:

  • @type t
  • @spec validate(term) :: Croma.Result.t(t)

Options:

  • :key_module - A module that defines the type of keys. The module must provide @type t and @spec validate(term) :: Croma.Result.t(t).
  • :value_module - A module that defines the type of values. The module must provide @type t and @spec validate(term) :: Croma.Result.t(t).
  • :min_size - Minimum size of valid values of this type (inclusive).
  • :max_size - Maximum size of valid values of this type (inclusive).
  • :default - Default value for this type. Passing this option generates default/0.

Examples

defmodule MyMap do
  use Croma.SubtypeOfMap, key_module: MyString, value_module: MyInt, default: %{}
end