Params v2.2.0 Params.Schema View Source

Defines a params schema for a module.

A params schema is just a map where keys are the parameter name (ending with a ! to mark the parameter as required) and the value is either a valid Ecto.Type, another map for embedded schemas or an array of those.

Example

   defmodule ProductSearch do
     use Params.Schema, %{
       text!: :string,
       near: %{
         latitude!:  :float,
         longitude!: :float
       },
       tags: [:string]
     }
   end

To get an Ecto.Changeset for ProductSearch params use:

   changeset = ProductSearch.from(params)

To transform the changeset into a map or %ProductSearch{}struct use Params.changes/1 or Params.data/1 respectively.