Request.Validator.Plug (RequestValidator v0.2.0) View Source

Link to this section Summary

Functions

Performs validations on conn.params If all validations are successful returns the connection struct Otherwise returns an error map in the following structure: %{param: ["some error", ...]} Will call the given on_error callback in case some validation failed

Init the Request.Validation.Plug with an optional error callback and handlers with their corresponding request validator module.

The default callback to be invoked when there is a param that fails validation.

Link to this section Functions

Performs validations on conn.params If all validations are successful returns the connection struct Otherwise returns an error map in the following structure: %{param: ["some error", ...]} Will call the given on_error callback in case some validation failed

Init the Request.Validation.Plug with an optional error callback and handlers with their corresponding request validator module.

plug Request.Validation.Plug,
  register: App.Requests.RegisterRequest,
  on_error: fn conn, errors -> json_resp(conn, "Handle your errors: #{inspect errors}") end

The default callback to be invoked when there is a param that fails validation.