https://github.com/walkr/lib_cleanex
Clean up your Elixir terms.
https://github.com/walkr/lib_cleanex
cleanup elixir
Last synced: 3 months ago
JSON representation
Clean up your Elixir terms.
- Host: GitHub
- URL: https://github.com/walkr/lib_cleanex
- Owner: walkr
- License: mit
- Created: 2018-07-06T01:10:03.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-09-25T01:52:32.000Z (over 5 years ago)
- Last Synced: 2025-03-18T21:51:13.964Z (3 months ago)
- Topics: cleanup, elixir
- Language: Elixir
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Cleanex
Clean up your Elixir terms.
By default it cleans strings (or any string values found inside maps, lists, keyword lists) by trimming ends, replacing double+ spaces, removing null-bytes; useful when working with user input.
### Installation
```elixir
def deps do
[
{:lib_cleanex, "~> 0.3.0"}
]
end
```### Usage
As function
```elixir
iex> Cleanex.clean(" hello world ")
"hello world"iex> Cleanex.clean(%{greeting: " hello world "})
%{greeting: "hello world"}iex> Cleanex.clean {" k ", " v "}
{"k", "v"}
```As plug for cleaning `conn.params`
```elixir
pipeline :api do
...
plug Cleanex.Plugs.ParamsCleaner
...
end
```#### Plug Options
`[strict: bool]` -- when `strict` is set to `false`, inner whitespace
won't be touched (default `true`)### Extend
To extend just implement `Cleanex.Cleanable` protocol for your own types.
MIT Licensed