Skip to content

Instantly share code, notes, and snippets.

@vetcovetco
Created April 19, 2017 00:41
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save vetcovetco/ff6bab9f30ad8d954edfcaca6b135199 to your computer and use it in GitHub Desktop.
require 'dry-validation'
tag = Dry::Validation.Schema do
required(:name).value(type?: :str?) # is this correct? I don't want to use .filled(:str?).
required(:name).value(:filled?)
required(:name).value(min_size?: 1)
required(:name).value(max_size?: 64)
end
tag.call({}).messages
=> {:name=>["is missing", "size cannot be greater than 64"]}
# Why doesn't DV tell me that the size cannot be less-than 1?
# Why doesn't DV tell me that :name must be a string?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment