These are chat archives for dry-rb/chat

2nd
Jul 2016
Tim Riley
@timriley
Jul 02 2016 00:18
@solnic yay, 👏🏻 on the release! 💃🏻💃🏻
Lauri Nevala
@nevalla
Jul 02 2016 07:58
bundler+rubygems issue seems to be fixed now and dry-logic 0.3.0 is found correctly :fireworks:
John Backus
@backus
Jul 02 2016 08:06
Oh wow
I thought our CI had some issue with dry-logic
What was the issue @nevalla?
Lauri Nevala
@nevalla
Jul 02 2016 08:17
I have no idea what was the actual issue, bundler just could not find dry-logic 0.3.0 dependency
John Backus
@backus
Jul 02 2016 08:58
Huh
well if anyone knows it confused the heck out of me today
Piotr Solnica
@solnic
Jul 02 2016 09:10
Yeah you can scroll up to see how it got me confused as well :laughing:
Piotr Solnica
@solnic
Jul 02 2016 09:42
@timriley thanks :) are you in front of your computer atm?
Tim Riley
@timriley
Jul 02 2016 10:59
@solnic maybe in 20 mins
dan-klasson
@dan-klasson
Jul 02 2016 14:34
anybody got this bundle require error before?
Bundler::GemRequireError: There was an error while trying to load the gem 'dry-validation'.
Gem Load Error is: uninitialized constant Dry::Types::Predicates
gem "dry-validation", "0.7.4"
Piotr Solnica
@solnic
Jul 02 2016 15:36
@dan-klasson uhm you gotta lock dry-types to 0.7.x with old dry-v
Sorry about that :/
dan-klasson
@dan-klasson
Jul 02 2016 15:37
after installing version 0.8.0 instead, the problem went away. i could i sworn i just successfully used 0.7.4 though
Piotr Solnica
@solnic
Jul 02 2016 15:37
i removed this module in dry-types 0.8
dan-klasson
@dan-klasson
Jul 02 2016 17:04
for dry-v, it doesn't support checking for a valid email address right? one would have to write a custom regex for that no?
Fran Worley
@fran-worley
Jul 02 2016 17:16
There is no built in email predicate. You could just use the format predicate and pass in your special regex
dan-klasson
@dan-klasson
Jul 02 2016 17:34
cool
getting some weird behavior with included_in. this works as expected: optional(:weight) {included_in?(["1", "2"]) }, but this optional(:weight) {included_in?(weights.keys) gives me ArgumentError: +weights+ is not a valid predicate name, even though it's an array like in the first example
is this due to some DSL magic?
Fran Worley
@fran-worley
Jul 02 2016 17:41
iI doub
can you try passing your weights.keys into another predicate e.g. Eql? and see if you get the same thing?
dan-klasson
@dan-klasson
Jul 02 2016 17:50
@fran-worley Yep, same thing
Fran Worley
@fran-worley
Jul 02 2016 17:51
Where does your weights variable come from?
dan-klasson
@dan-klasson
Jul 02 2016 17:52
      def self.weights
        {"0" => "Nice!", "1" => "Rubbish!"}
      end
the value of weights.keys is ["0", "1"]
Brent Jubinville
@utilityboy
Jul 02 2016 18:05
Is there a way to compose hash schemas? I have a "base schema" containing a timestamp that defaults to Time.current and would like all inherited schema types to include that as well.
Piotr Solnica
@solnic
Jul 02 2016 18:06
@dan-klasson exection context of the dsl is not the schema class so no access to its methods
err execution
dan-klasson
@dan-klasson
Jul 02 2016 18:08
@solnic Not sure if I understand what you mean. What should I be using instead?
Piotr Solnica
@solnic
Jul 02 2016 18:16
Dont use a block
oh wait thay wont work
Assign this keys to a constant so it is available
We should provide some api for this kind of stuff i guess
For now constants or class methods
So ie YourSchema.weights.keys
dan-klasson
@dan-klasson
Jul 02 2016 18:18
constant didn't work either
oh wait, it did
i'm using it with TRB, so it's in a validation block, not a schema
Fran Worley
@fran-worley
Jul 02 2016 18:23
@dan-klasson the two are one in the same. All reform does is put your validation block into a schema
dan-klasson
@dan-klasson
Jul 02 2016 18:24
yeah but there isn't a class to reference such as YourSchema
or maybe there is, i just don't know the name
Fran Worley
@fran-worley
Jul 02 2016 18:25
Yeah you're right you cant do that at the moment but I plan on updating reform to make this kind of thing available.
dan-klasson
@dan-klasson
Jul 02 2016 18:26
that'd be sweet. i guess i can resort to hardcoding it for now
Piotr Solnica
@solnic
Jul 02 2016 19:08
it's...already hardcoded in your method, just a matter of calling it explicitly as dsl context is Dry::Validation::Schema::DSL object