MapSchema.Examples.CustomTypeRecursive.ListPeople (map_schema v0.2.6) View Source

List type

Recursive List of people using Person map_schema

Link to this section Summary

Functions

We take a list of people and we need cast each person creating a new map that will be checked with the schema of Person.

## Example

If the cast it´s right then always will be valid. because we are using a schema then is_valid? is always true

Callback implementation for MapSchema.CustomType.name/0.

Callback implementation for MapSchema.CustomType.nested?/0.

Link to this section Functions

Specs

cast(any()) :: any() | :error

We take a list of people and we need cast each person creating a new map that will be checked with the schema of Person.

Example:

iex> alias MapSchema.Examples.CustomTypeRecursive.ListPeople
iex> lista_friends = [%{"name"=> "bob"},%{"name"=>"mary"}]
iex> ListPeople.cast(lista_friends)
[%{"name"=> "bob"},%{"name"=>"mary"}]

iex> alias MapSchema.Examples.CustomTypeRecursive.ListPeople
iex> lista_friends = [%{"name"=> "bob"},%{"name"=> 222}]
iex> ListPeople.cast(lista_friends)
:error

Specs

doctest_values() :: [{any(), any()}]

## Example:

iex> alias MapSchema.Examples.CustomTypeRecursive.ListPeople
iex> ListPeople.doctest_values()
[{"[%{\"name\"=> \"bob\"},%{\"name\"=>\"mary\"}]","[%{\"name\"=> \"bob\"},%{\"name\"=>\"mary\"}]"}]

Specs

is_valid?(any()) :: boolean()

If the cast it´s right then always will be valid. because we are using a schema then is_valid? is always true

Specs

name() :: atom()

Callback implementation for MapSchema.CustomType.name/0.

Callback implementation for MapSchema.CustomType.nested?/0.