Skip to content

mtkachenk0/paradocs

Repository files navigation

Paradocs: Extended Parametric gem + Documentation Generation

Ruby

Declaratively define data schemas in your Ruby objects, and use them to whitelist, validate or transform inputs to your programs.

Useful for building self-documeting APIs, search or form objects. Or possibly as an alternative to Rails' strong parameters (it has no dependencies on Rails and can be used stand-alone).

Installation

$ gem install paradocs

Or with Bundler in your Gemfile.

gem 'paradocs'

Getting Started

Define a schema

schema = Paradocs::Schema.new do
  field(:title).type(:string).present
  field(:status).options(["draft", "published"]).default("draft")
  field(:tags).type(:array)
end

Populate and use. Missing keys return defaults, if provided.

form = schema.resolve(title: "A new blog post", tags: ["tech"])

form.output # => {title: "A new blog post", tags: ["tech"], status: "draft"}
form.errors # => {}

Learn more

Please read the documentation

About

Ruby validation and documentation generation. Write validation code and get generated documentation that you don't have to maintain!

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages