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

This module provides a type for validating maps.

Maps have a schema that defines the keys and their respective types.

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

Summary

Types

@type key() :: String.t() | atom() | {:optional, String.t()} | {:optional, atom()}
@type t() :: %Shapex.Types.Map{fields: %{required(key()) => Shapex.Type.t()}}

Functions

@spec validate(t(), map()) :: {:ok, :valid} | {:error, term()}

Callback implementation for Shapex.Type.validate/2.