# NimbleOptions

[![ badge](](
[![Documentation badge](][docs]
[![Coverage Status](](

[Online Documentation][docs].

A tiny library for validating and documenting high-level options.

This library allows you to validate options based on a definition.
A definition is a keyword list specifying how the options you want
to validate should look like:

definition = [
  connections: [
    type: :non_neg_integer,
    default: 5
  url: [
    type: :string,
    required: true

Now you can validate options through `NimbleOptions.validate/2`:

options = [url: ""]

NimbleOptions.validate(options, definition)
#=> {:ok, [url: "", connections: 5]}

If the options don't match the definition, an error is returned:

NimbleOptions.validate([connections: 3], definition)
   keys_path: [],
   message: "required option :url not found, received options: [:connections]"

`NimbleOptions` is also capable of automatically generating
documentation for a definition by calling ``
with your definition.

## Installation

You can install `nimble_options` by adding it to your list of
dependencies in `mix.exs`:

def deps do
    {:nimble_options, "~> 1.0"}

## Nimble*

All nimble libraries by Dashbit:

  * [NimbleCSV]( - simple and fast CSV parsing
  * [NimbleOptions]( - tiny library for validating and documenting high-level options
  * [NimbleParsec]( - simple and fast parser combinators
  * [NimblePool]( - tiny resource-pool implementation
  * [NimblePublisher]( - a minimal filesystem-based publishing engine with Markdown support and code highlighting
  * [NimbleTOTP]( - tiny library for generating time-based one time passwords (TOTP)

## License

Copyright 2020 Dashbit

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at


  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  See the License for the specific language governing permissions and
  limitations under the License.