Pharams v0.6.0 Pharams View Source
Functions and macros for validating requests to Phoenix Controllers.
Link to this section Summary
Functions
This macro provides the ability to define validation schemas for use in Phoenix controllers
Takes a nested struct data structure and turns it into a map
Link to this section Functions
This macro provides the ability to define validation schemas for use in Phoenix controllers
Example
use Pharams, view_module: Pharams.ErrorView, view_template: "errors.json", error_status: :unprocessable_entity
pharams :index do
required :terms_conditions, :boolean
required :password, :string
required :password_confirmation, :string
optional :age, :integer
end
def index(conn, params) do
# You will only get into this function if the request
# parameters have passed the above validator. The params
# variable is now just a map with atoms as keys.
render(conn, "index.html")
end
Takes a nested struct data structure and turns it into a map