Goal - A parameter validation library based on Ecto

Goal 0.2.1 released! :partying_face:

This update adds a neat feature called recase_keys/3, which recases parameter keys from e.g. camelCase to snake_case (i.e. what was defined in the defparams schema).

It’s an optional feature that can be enabled by passing the :recase_keys option to validate/3 or validate_params/3, or by setting :recase_keys in the application config:

config :goal,
  recase_keys: [from: :camel_case]

The supported cases are camelCase, PascalCase, kebab-case and snake_case. The common use-case is for JSON APIs where frontend and backend applications may have different parameter key formats.

Example:

MySchema.validate(:show, %{"firstName" => "Jane"})
{:ok, %{first_name: "Jane"}}

I added Recase as a dependency to handle the string recasing :bowing_man:

1 Like