timriley on rich-component-dirs-config
Add component_dirs setting Rem… Scan component file for magic c… Make load_component easier to u… (compare)
timriley on rich-component-dirs-config
Fix wording Add Rubocop rule Clarify names Fixup naming and 4 more (compare)
flash-gordon on master
Add more predicates to mapping (compare)
timriley on rich-component-dirs-config
Use base Dry::Container missing… (compare)
gem 'dry-validation', '~> 0.10'
require 'dry/validation'
schema =
Dry::Validation.Schema do
required(:foo) { str? }
required(:bar) { str? | int? }
end
schema.call(foo: 1, bar: 'blah').message_set.first.text # => "must be a string"
begin
schema.call(foo: 'hi', bar: 1.0).message_set.first.text
rescue => err
p err
end
# >> #<NoMethodError: undefined method `text' for #<Dry::Validation::Message::Or:0x007fbcb32514b8>>
gem 'dry-validation', '~> 0.10'
require 'dry/validation'
SCHEMA =
Dry::Validation.Schema do
required(:foo) { str? }
required(:bar, %i[string int]) { str? | int? }
end
SCHEMA.call(foo: 1, bar: 'blah').message_set.first.to_s # => "must be a string"
begin
SCHEMA.call(foo: 'hi', bar: 1.0).message_set.first.to_s # => "must be a string or must be an integer"
rescue => err
p err
end
Result#errors
and Result#hints
/home/monkey/.gem/ruby/2.2.5/gems/dry-types-0.9.0/lib/dry/types/compiler.rb:80:in `merge': no implicit conversion of Dry::Types::Safe into Hash (TypeError)
from /home/monkey/.gem/ruby/2.2.5/gems/dry-types-0.9.0/lib/dry/types/compiler.rb:80:in `each'
case
for simple ugh ... cases
messages
that merge both errors and hints, this turned out to be problematic in some cases so it was separated in 0.10.0