bluzky
Tarams, simplest library to parse and validate params
Hi, I have just published a new package named tarams. It provide a simple way to define schema, parse and validate your request parameters.
Here is how to use Tarams
@index_params_schema %{
keyword: :string,
status: [type: string, required: true],
group_id: [type: :integer, validate: {:number, [greater_than: 0]}]
}
def index(conn, params) do
with {:ok, better_params} <- Tarams.parse(@index_params_schema, params) do
IO.inspect(better_params.keyword}
IO.inspect(better_params.status}
IO.inspect(better_params.group_id}
# do anything with your params
else
{:error, changset} -> # return params error
end
end
Your feedback are welcome!
Most Liked
bluzky
Release v1.0.0
I try to support nested schema but using Ecto, it’s hard to support nested schema without some hack.
So I decide to rewrite Tarams and remove dependency on Ecto.
Now you can work with nested params easily like this:
@user_schema %{
name: :string,
email: [type: :string, required: true],
address: %{
street: :string,
district: :string,
city: :string
}
}
Tarams.cast(params, @user_schema)
3
LostKobrakai
This looks quite similar to what nimble_options does.
1
Popular in Libraries
Hey guyz
We at @aviabird are working on a payment library in elixir/phoenix. We are targeting March 2018 to add 56 Gateways to it.
Have...
New
I released Doggo, a collection of unstyled Phoenix components.
Features
Unstyled Phoenix components.
Storybook that can be added to...
New
simple_feature_flags is a tiny package that lets you turn features on or off based on which environment (e.g. localhost, staging, product...
New
EDIT: since Ecto 3.0 final version is out, this post was amended to use the final versions in the instructions below.
Hi everyone,
We a...
New
Hi!
I wanted to introduce my latest project LiveSvelte. It allows you to render Svelte inside LiveView with end-to-end reactivity. It’s ...
New
Hey there!
I wrote a download elixir package which does exactly what its name about - an easy way to download files.
I saw solutions ...
New
I created a new library GitHub - benvp/ex_cva: Class Variance Authority for Elixir which aims to make it very easy to define different va...
New
Hi, I just published version 0.23.0 of Elixirscript.
Most of the changes are around JavaScript interop now that Elixirscript uses the ...
New
Bandit is an HTTP server for Plug and WebSock apps.
Bandit is written entirely in Elixir and is built atop Thousand Island. It can serve...
New
Grizzly is a library for working with Z-Wave devices. Z-Wave is a low-frequency radio protocol for controlling smart home devices on a me...
New
Other popular topics
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this:
...
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set?
Thanks.
New
Hi,
I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch.
This project took far...
New
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
I have a super simple question about elixir - how would I take a file like this
foo bar baz
and output a new file that enumerates th...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New







