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
Popular in Announcing
I’d like to announce a small library called boundaries.
This is an experimental project which explores the idea of enforcing boundaries ...
New
I created a new library (rather I pulled out a couple files from my big project), it manages an operating system PID file for the BEAM.
...
New
Yes, yet another parser combinator library!
Most of the parser combinators in the ecosystem are either compile-time, often using AST tra...
New
The latest release of Ace (0.10.0) includes serving content over HTTP/2.
I have started writing a webserver to teach my self more about...
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
ex_cldr provides localisation and internationalisation support based upon the data from the Unicode CLDR project.
Unicode released CLDR ...
New
WebAuthnLiveComponent WebAuthnComponents
See this post about renaming the package.
Passwordless authentication for Phoenix LiveView app...
New
Only 650 LOC, wrote for fun :slight_smile:
https://github.com/sunboshan/qrcode
New
Hi everyone,
I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
Other popular topics
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Hello everyone,
I try to use an Javascript Event Handler in my root.html.leex file.
Therefore I created a function in the app.js file: ...
New
I have VueJS GUIs with the project generated using Webpack.
I have Elixir modules that will need to be used by the VueJS GUIs.
I forese...
New
Hello!
tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability.
After spen...
New
Hi everyone,
One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









