These are chat archives for dry-rb/chat

5th
Jun 2017
Christian Meier
@mkristian
Jun 05 2017 12:38
@stergiom oh this /Users/usr/Dev/app/out/uri:classloader:/ looks bad and I do remember that Pathname still has issues with JRuby when running from a packed jar. please try something like File.expand_path('../../../../config/errors.yml', __dir__) as all the File methods support the classloader schema of JRuby much better. please ping me if you can not figure out. not sure where exactly things blow up but it could be also the realpath. and it would be nice to file an issue with jruby itself, so the Pathname can be improved for the jarred file cases.
Stergio
@stergiom
Jun 05 2017 13:55
@mkristian the issue seems to be with JRuby's Kernel#__dir__ which breaks in the File.expand_path(..) approach too, I'll file an issue with JRuby about it. I've managed to work around it with File.dirname(__FILE__) (works with Pathname too)
# either works..
DEFAULT_PATH = Pathname(File.dirname(__FILE__)).join('../../../../config/errors.yml').realpath.freeze
DEFAULT_PATH = File.expand_path('../../../../config/errors.yml', File.dirname(__FILE__)).freeze
Nick Gorbikoff
@konung
Jun 05 2017 18:58
Hi.
Question about dry-validation. Specifically about custom error codes. I have an example working, where it grabs custom error message, from the file specified. But is there a way to configure this globally, so i don’t have to do it for each custom predicate/validator? I have 10 right now. Here is a sample
    validation :unique, if: :default do
      configure do
        config.messages_file = Rails.root.join('config/locales/errors.yml')
        def unique?(value)
          !Rate.exists?(code: value)
        end
      end
      required(:code, &:unique?)
    end
that config.messages_file. Anyway to make this a global setting for the whole gem?
I use Rails
And the whole TRB 2 stack
Thank you
Nikita Shilnikov
@flash-gordon
Jun 05 2017 21:26
Nick Gorbikoff
@konung
Jun 05 2017 21:31
Oh and then everything can “inherit" from that ? Awesome. I missed it somehow. Thank you!
Composition rocks!
Nikita Shilnikov
@flash-gordon
Jun 05 2017 21:32
:)