Therapy

Get it? Therapy... validation... come on!

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      therapy:
        github: matthewmcgarvey/therapy
  2. Run shards install

Usage

require "therapy"

sign_up_form = Therapy.object(
  email: Therapy.string.coercing,
  password: Therapy.string.coercing,
  confirm: Therapy.string.coercing
).coercing.validate("Confirm must match password") do |form|
  form[:password] == form[:confirm]
end

json = JSON.parse(request.body)
sign_up = sign_up_form.parse!(json) #=> NamedTuple(email: String, password: String, confirm: String)

TODO Write usage instructions here

Development

TODO Write development instructions here

TODO

Contributing

  1. Fork it (https://github.com/matthewmcgarvey/therapy/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors