https://github.com/am-kantox/nimble_options_ex
Set of custom functions to enhance the UX with `NimbleOptions`
https://github.com/am-kantox/nimble_options_ex
Last synced: 23 days ago
JSON representation
Set of custom functions to enhance the UX with `NimbleOptions`
- Host: GitHub
- URL: https://github.com/am-kantox/nimble_options_ex
- Owner: am-kantox
- License: other
- Created: 2023-04-08T06:50:11.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-18T08:46:35.000Z (about 1 month ago)
- Last Synced: 2025-03-18T09:37:58.801Z (about 1 month ago)
- Language: Elixir
- Size: 20.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NimbleOptionsEx [](https://kantox.com/)  
## Addons to [`NimbleOptions`](https://hexdocs.pm/nimble_options)
### `behaviour/2`
```elixir
schema = [
container: [
required: true,
type: {:custom, NimbleOptionsEx, :behaviour, [Supervisor]},
doc: "The implementation of `Supervisor` to be used as a supervisor"
]
]NimbleOptions.validate([container: DynamicSupervisor], schema)
#⇒ {:ok, [container: DynamicSupervisor]}NimbleOptions.validate([container: DateTime], schema)
#⇒ {:error, %NimbleOptions.ValidationError{
# message: "[…] ‹DateTime› does not implement requested callbacks ‹[init: 1]›",
# key: :container, value: DateTime, keys_path: []}}
```### `access?/1`
```elixir
schema = [
container: [
required: true,
type: {:custom, NimbleOptionsEx, :access?, []},
doc: "The implementation of `Access` to be used as a storage"
]
]NimbleOptions.validate([container: %{}], schema)
#⇒ {:ok, [container: %{}]}
NimbleOptions.validate([container: [foo: :bar]], schema)
#⇒ {:ok, [container: [foo: :bar]]}
NimbleOptions.validate([container: [1, 2, 3]], schema)
#⇒ {:error, %NimbleOptions.ValidationError{
# message: "[…] expected a keyword list, got a list ‹[1, 2, 3]›",
# key: :container, value: [1, 2, 3], keys_path: []}}
```## Installation
```elixir
def deps do
[
{:nimble_options_ex, "~> 0.1"}
]
end
```## [Documentation](https://hexdocs.pm/nimble_options_ex)