/dry-val.rb Secret
Created
April 19, 2017 00:41
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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