Taly.Validate (taly v0.1.2)

Link to this section Summary

Functions

Validate data. if you not use defmarco function final/1, return {:ok, output} or {:error, [%Taly.ValidateError.t()]}.

Link to this section Functions

Link to this function

validate(schema_or_form, data, kwargs \\ %{})

Specs

validate(
  %Taly.Form{final: term(), schema: term()} | keyword(),
  map() | keyword(),
  map()
) ::
  {:ok, :any}
  | {:error,
     [
       %Taly.ValidateError{
         __exception__: term(),
         message: any(),
         path: list(),
         value: any()
       }
     ]}

Validate data. if you not use defmarco function final/1, return {:ok, output} or {:error, [%Taly.ValidateError.t()]}.

  • schema_or_form - the input data is keyword or Taly.Form.

  • data - input data. keyword or map.

  • kwargs - default value is %{}, This parameter can be filled with your own data.

Example

Taly.Validate.validate(schema, data)
# or
Taly.Validate.validate(schema, data, %{mydata => [config: %{mode: :low}]})