Skip to content

Instantly share code, notes, and snippets.

@blelump

blelump/dryv.rb Secret

Created March 10, 2016 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blelump/f92902ab4c2291aa3b5b to your computer and use it in GitHub Desktop.
Save blelump/f92902ab4c2291aa3b5b to your computer and use it in GitHub Desktop.
require 'bundler'
Bundler.require
schema = Dry::Validation.Schema do
key(:email).required
key(:age).required(:int?, gt?: 18)
end
form = Dry::Validation.Form do
key(:email).required
key(:age).required(:int?, gt?: 18)
end
[schema, form].each do |caller|
errors = caller.(email: 'jane@doe.org', age: 19).messages
puts errors.inspect
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment