Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Simon Schmid
@sled
I think the only external gem dependency of dry-* is the Kleisli gem
Andy Holland
@AMHOL
Also concurrent-ruby
Simon Schmid
@sled
yep concurrent-ruby is a beast ;)
Andy Holland
@AMHOL
It is indeed, I preferred thread-safe TBH
But again, people don't want too many dependencies, so lets have a gem for utitility classes, a gem for managing concurrency and a gem for active anything
I can't wait to see what Tim does with https://github.com/icelab/dry-web-skeleton tho, hopefully will be able to get the full stack running on top of dry and rom soon
Fran Worley
@fran-worley
It would be good to hear Piotr's opinion but I remember him saying a while ago that his vision for Macros was to enable people to build their own. I know that there was talk a while ago of building something into Reform to make the migration to Dry-V easier.
Andy Holland
@AMHOL
Oh cool, I guess I missed that
Fran Worley
@fran-worley
I could be wrong and I know that at this stage it's not been explored to its full potential but that combined with custom processors for inputs and errors would in theory allow you to 'wrap' the library.
Tim Riley
@timriley
I think Piotr and Luca may have different opinions on the importance of validation.
I can see Luca's opinion on the API stability front. It's something he's decided to take on, with hanami being a "one stop shop"/all-encompassing solution for developers, something they can rely on above all else.
I guess it's a bit different to how an app using e.g. dry-web or other non-frameworks is put together, where you decide to use whichever gems you want, and then learn/use them directly and keep on top of any API changes they may (or may not) ever need.
(I know that's possible with hanami too, but in offering a full range of functionality as an in-house option, I'd imagine the majority of hanami users would follow that path)
Tim Riley
@timriley
Anyway, the improvements to their validation system look nice! Even if they cover similar ground to dry-v.
I'll release a dry-web gem release today and try to get some minimal docs in our icelab skeleton, @AMHOL :)
I also want to think about what constitutes a viable minimum skeleton too, something perhaps less opinionated than ours (which comes out of the box with things like a background job runner, etc., things that people might not necessarily want).
On dependencies, they're not something people should be afraid of, especially the right type of dependencies :)
Andrew Kozin
@nepalez
@timriley thanks! with my rungnish writing a post is too time-consuming challenge. I'd postpone it to the weekend
Tim Riley
@timriley
@nepalez no worries, take your time :) BTW, if you need a hand with proof-reading/minor editing, I'm happy to help.
Tim Riley
@timriley
dry-web just got its first rubygems release: http://rubygems.org/gems/dry-web
Tim Riley
@timriley
I also started documenting the skeleton that we use for icelab dry-web projects: https://github.com/icelab/dry-web-skeleton
Fran Worley
@fran-worley
@timriley looks good I'll try and find the time to have a play with it at the weekend!
Tim Riley
@timriley
@fran-worley cool! Would love your feedback on how things feel. In the next 2 months, I want to focus on massively improving the dry-web experience for newcomers.
S/massively/as best I can/ :)
Tim Cooper
@coop
Tim Riley
@timriley
Oh, thanks @coop!
Benjamin Klotz
@tak1n
@timriley awesome, I think I will soon start a toy project with dry-web etc :)
Tim Cooper
@coop
It was a good explaination without touting that “it is better”. Well done.
Fran Worley
@fran-worley
@timriley you have the power of words my friend. I avoid trying to put my thoughts in comments as I just sound opinionated... Well said!
Tim Riley
@timriley
Ta :blush:
@tak1n great! Would love to hear how you go. Let me know if you have question.
BTW, at Icelab we're currently building our now company site as a dry-web app started from this skeleton. It's still very early, but it may serve as a helpful point of reference. It's on GitHub as icelab/berg.
Benjamin Klotz
@tak1n
@timriley cool thx :D
Tim Riley
@timriley
I hope to bring our other young example app (icelab/Alpinist) up to date soon too. that one hasn't been touched since December, and we've progressed our dry-web setup a fair bit since then.
Benjamin Klotz
@tak1n
yea I have seen it, I was curious how dry-v was used in dry-web and in alpinist you subclass Dry::V::Schema which is no longer possible I think
Tim Riley
@timriley
Yeah. Old school and now broken :grimacing:
Fran Worley
@fran-worley
@timriley is it worth adding your explanation of dry-v #113 to the dry-rb.org site?
It might be useful to just explain the purpose of the
Tim Riley
@timriley
Yeah, I reckon.
Kuba Krzempek
@kubakrzempek

Hi everyone, I'm writing a form object powered by dry-validation. Let's say the form has two keys - :code and :organization_id.
I want to validate whether a pair [:code, :organization_id] is unique in my db, yet I'm failing in doing so.
First I though about using rule(uniq_code: [:code, :organization_id]) but it clearly wants me to run predicates on the keys I've passed into it, so I decided to go with my custom predicate and ended up with the following

Create = Dry::Validation.Form do
  key(:code).required(uniq?: "organization_id")
  key(:name).required
  key(:countries_id).required
  key(:description).required
  key(:organization_id).required
  key(:active).required

  configure do
    option :market_repo, WheelsApp.instance["repositories.market"]

    def uniq?(organization_id, value)
      # query logic here
    end
  end

How can I pass to uniq? method a value of :organization_id that comes from object I've passed into the form?

I tried with value(:organziation_id) but that returns something like an ast graph
Tim Riley
@timriley
@kubakrzempek if you want to work on the two at once, I think you need to make a "high level rule" (it's in the docs) which could then pass those two values to a predicate to check for uniqueness of both
Simon Schmid
@sled
not sure whether it works though ;)
Kuba Krzempek
@kubakrzempek
@timriley @sled thank you for your answers. As you suggested I went back on "high level rule" track and it looks like this now
https://gist.github.com/kubakrzempek/f6c15643b9adae7e3de27a6b946aee30
but it still doesn't work, because sequel queries expect organization_id and code to be values, not Dry::Validation::Schema::Rule objects.
I commented the unique? method's body and returned false explicitly, and the rule(:uniq_code_organization) failed, because it didn't expected to receive a FalseClass object.
Do you know any other way to implement block assigned to rule?
Andy Holland
@AMHOL
@kubakrzempek you know you passed the arguments to unique? in the wrong order?
@kubakrzempek I'm not sure how to do what you're trying to do but looking at http://dry-rb.org/gems/dry-validation/high-level-rules/ and http://dry-rb.org/gems/dry-validation/custom-predicates/ what you have so far isn't right
Christopher Dennl-Ortega Arrieta
@cdennl
@AMHOL no it is not wrong order
Andy Holland
@AMHOL
It's also better to have your repositories return materialized results, rather than having query logic leak out into other parts of your application
Christopher Dennl-Ortega Arrieta
@cdennl
@AMHOL the order is reversed