Next-gen ruby libs! » github.com/dry-rb » website: https://dry-rb.org » forum: https://discourse.dry-rb.org
irb(main):004:0> Dry::Validation.Schema { required(:num).value(:int?) }.(num: 'not num').results[0].ast
=> [:key, [:num, [:predicate, [:int?, [[:input, “not num”]]]]]]
^^ here’s a result AST, gives you all info you need to generate whatever you want from it
+puts+ is not a valid predicate name
rule(valid_blockname: [:ist_blockname, :name]) do |ist_blockname, name|
puts ist_blockname
end
before(:all) { load_extension }
is a bad approach, should be reworked in the same way as in dry-t
dry-logic
broke rom-sql
build (master) See https://gist.github.com/jodosha/55651fe8033477cba882c2af17ee8c9a.
dry-types
(master) in Gemfile
fixes the problem. :)
@solnic @flash-gordon just updated dry-v on one of our gems and got the same problem :)
https://gist.github.com/tak1n/79c180ac09fbacbae0f432169798233b
gem 'dry-struct', github: 'dry-rb/dry-struct'
gem 'dry-validation', github: 'dry-rb/dry-validation'
gem 'dry-types', github: 'dry-rb/dry-types'
putting this into Gemfile fixes the problem
bundle update
and tried it explicitly on some gems bundle update --source dry-validation
etc
There's also a WIP feature in dry-validation where you can infer validations from a struct definition. It's been in an experimental phase since a couple of releases but we're gonna make it robust prior 1.0.0. (by @solnic)
Is it possible to use this feature, or at lease try it now?
bundle update
:laughing:
dry-validation
?value_or
should be in Try
monad as well ?
Xor
monad(right biased Either)
value_or
this would be strange a bit. This means you're silently ignoring exception value which is usually not a good idea
my_try.to_maybe.value_or
required(:urls).value(min_size?: 1) { each(:str?, :url?) }
/home/monkey/.gem/ruby/2.2.5/gems/dry-validation-0.10.0/lib/dry/validation/schema/value.rb:1:in `require': cannot load such file -- dry/struct (LoadError)
from /home/monkey/.gem/ruby/2.2.5/gems/dry-validation-0.10.0/lib/dry/validation/schema/value.rb:1:in `<top (required)>'
from /home/monkey/.gem/ruby/2.2.5/gems/dry-validation-0.10.0/lib/dry/validation/schema.rb:7:in `require'
from /home/monkey/.gem/ruby/2.2.5/gems/dry-validation-0.10.0/lib/dry/validation/schema.rb:7:in `<top (required)>'