Therapy
Get it? Therapy... validation... come on!
Installation
-
Add the dependency to your
shard.yml:dependencies: therapy: github: matthewmcgarvey/therapy -
Run
shards install
Usage
require "therapy"
sign_up_form = Therapy.object(
email: Therapy.string,
password: Therapy.string,
confirm: Therapy.string
).validate("Confirm must match password", path: ["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
- Unions
- String OR Int
- Array of Bools AND Strings
- Two Different Object Structures
- Hashes (for when keys are unknown/dynamic)
- more validations/transformations
Contributing
- Fork it (https://github.com/matthewmcgarvey/therapy/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- matthewmcgarvey - creator and maintainer