Magik.Validator.validate_map

You're seeing just the function validate_map, go back to Magik.Validator module for more information.
Link to this function

validate_map(data, validations_spec)

View Source

Specs

validate_map(map(), map()) :: :ok | {:error, map()}

Validate map value with given map specification. Validation spec is a map

validation_spec = %{
  email: [type: :string, allow_nil: false],
  password: [type: :string, length: [min: 8]],
  age: [type: :integer, number: [min: 16, max: 60]]
}

validate_map use the key from validation to extract value from input data map and then validate value against the validators for that key.

In case of error, the error detail is a map of error for each key.

iex(56)> Magik.Validator.validate_map(%{name: "dzung", password: "123456", emal: "ddd@example.com", age: 28}, validation_spec)
{:error, %{password: "length must be greater than or equal to 8"}}