These are chat archives for dry-rb/chat

13th
Jun 2016
Sam Stickland
@samstickland
Jun 13 2016 07:51
Hello. Is there anything like shoulda-matchers for dry-validation? And if not, I'm curious to know how test cases for schemas are written.
Tim Riley
@timriley
Jun 13 2016 08:24
I’d imagine you’d just test with various permutations of input data and then check that you get the output/error messages that you want for each
Nothing special, really.
Oskar Szrajer
@gotar
Jun 13 2016 08:27
you always can check repo spec directory
Tim Riley
@timriley
Jun 13 2016 12:15
Spent today working on an app config loader and I’m not sure I like it at all :\
Joshua Wilcox
@joshuaswilcox
Jun 13 2016 14:15
Could someone point me in the direction of a good example of using dry-validation with dry-types
i can't seem to figure out the best way to work with them together
i was trying to avoid the duplication padding parameters to an schema then pulling the hash attributes out to pass to the attribute calls, but maybe thats the best approach
Oskar Szrajer
@gotar
Jun 13 2016 14:19
@timriley why dry-web is not related to roda directly anymore? I was sure it will be next framework that glue ROM, Roda and Dry-* together
Andy Holland
@AMHOL
Jun 13 2016 15:20
@gotar there's a dry-web-roda repo now
So dry-web is decoupled from framework
Or routing mechanism or w.e.
zuuno
@zuuno
Jun 13 2016 15:25

Hi guys, a little question:
Is it possible with High-level rules to compare the value of an input with a dynamically value.
For instance, I'm validating invoice lines inputs, and I'd like to validate that their currency is the same as their parent object (the invoice).

Best,

Oskar Szrajer
@gotar
Jun 13 2016 15:33
Yeap I know but for me it loose his purpose. For me dry-web was whole web framework, not it's not
I ask about direction did there will be dry-web-hanami, dry-web-rails ... ?
Andy Holland
@AMHOL
Jun 13 2016 15:50
Ahh, yeah, @solnic already worked on a dry-web-hanami prototype a while back
Before the name change obviously :p
Oskar Szrajer
@gotar
Jun 13 2016 15:51
yeah, but them he (I think) to decide to create new full framework on top of ROM, Roda, Dry, and now I see it's back to sth else, sth less
Oskar Szrajer
@gotar
Jun 13 2016 16:09
Hmm what can cause those error?
/Users/gotar/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/dry-validation-8329e0bb7a1c/lib/dry/validation/predicate_registry.rb:65:in `ensure_valid_predicate': undefined method `arity' for #<Dry::Logic::Predicate id=:key? args=[]> (NoMethodError)
my validator:
require "dry-validation"

module Validations
  class CommentValidator
    CommentSchema = Dry::Validation.Form do
      required(:post_id).filled(:int?)
      required(:body).filled(:str?)
    end

    def call(args)
      CommentSchema.call(args)
    end
  end
end
works fine before last update to master, probably sth change?
Piotr Solnica
@solnic
Jun 13 2016 16:10
@zuuno yes ie foo.eql?(bar) where foo and bar are high-lvl rule values
@gotar pull lates dry-logic
Oskar Szrajer
@gotar
Jun 13 2016 16:12
eh ok ;]
ok one error less, hard to follow all those maser changes, I got I think last error before moving to dry-web-rom from dry-web
/Users/gotar/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/dry-component-bd56097a58f2/lib/dry/component/container.rb:220:in `check_component_identifier!': component identifier +rom+ is invalid or boot file is missing (ArgumentError)
i have those rom file in boot dir
works perfect before
probably miss some changes in container or component?
Joshua Wilcox
@joshuaswilcox
Jun 13 2016 16:33
So on the validation/type integration the best I can think of is ThingSchema.(ThingType.new(thing1: 123, thing2: 321).to_h)
i don't like having to define the attributes twice though in both Validation and Type, is there a way for a Type to take a schema?
zuuno
@zuuno
Jun 13 2016 16:37
@solnic thx, but I still have this: Unable to send 'eql?' on instance of BasicObject
(I'm using: item_currency.eql?(document.currency))
Joshua Wilcox
@joshuaswilcox
Jun 13 2016 17:18
Can DateTime attributes in dry-type be Maybe It does seem to work
Andy Holland
@AMHOL
Jun 13 2016 17:19
@gotar could be that the core directory is now called components by default?
On dry-component master
Oskar Szrajer
@gotar
Jun 13 2016 19:29
eh ok thx thats explain a lot ;]
best is that still on all spec examples like in dry-web-roda there is still core directory
Tim Riley
@timriley
Jun 13 2016 20:37
@gotar ah, I'll adjust that today. Sorry for the disturbance.
John Backus
@backus
Jun 13 2016 21:24
Is there any concept of a compound error message for dry-validation?
For example, in our API we want to allow JSON where the { "first": "John", "middle": "C", "last": "Backus" } and { "first": "John", "last": "Backus" } are both valid but { "first": "John", "middle": null, "last": "Backus" } is not valid
Hence we have a schema with
required('first').value(:str?)
optional('middle').value(:str?)
required('last').value(:str?)
So I'd love a "compound" error message here
because I want to tell our user that "middle must be a string or not provided"
John Backus
@backus
Jun 13 2016 21:30
cc @solnic ^
Piotr Solnica
@solnic
Jun 13 2016 23:36
@backus please report a feature request
John Backus
@backus
Jun 13 2016 23:38
Will do
Tim Riley
@timriley
Jun 13 2016 23:54
@gotar that’s updated in dry-web-roda master now.
@gotar and the idea with dry-web is to build a container/component-oriented web app which can work with any number of routing front-ends. Roda is just the first :)
Each combination with a routing front-end will come with its own appropriate set of conventions and “glue” code.
If all you’re interested in is roda, then dry-web-roda is the place for you :)