Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Nikita Shilnikov
@flash-gordon
if you return Left/Right from QcSilence, map will wrap it once again
so you'll get Right(Right(...)) or Right(Left(...))
Uros Jurglic
@jurglic
Aha, I see.
Piotr Solnica
@solnic
according to docs, map always returns Right
Uros Jurglic
@jurglic
So you think my approach is somewhat acceptable? :D
@solnic Thanks Piotr yeah I saw that one, that's why I was confused before.
Piotr Solnica
@solnic
feels like an overhead though, if it always returns Right then maybe it’d be better to just pass plain values
Uros Jurglic
@jurglic
So the first 3 operations, - as implemented now - can return Left or Right. However they are independent. And now new requirement came they should run always no matter if any of them failed in a previous step.
So I'm trying to figure out what's the approach best aligned with dry-transaction.
Tim Riley
@timriley
Right now, it feels like it's be better just to run those three things in a custom class
@apotonick's pipetree stuff in trailblazer 2 makes me want to enrich some of the functionality of dry-transaction, but in a little while
Nick Sutterer
@apotonick
@timriley i was evaluating it
and decided to use my own pipetree stuff that is approved to work in representable, and is super fast
it's very important for that to be fast, since i want to use pipetree for all my gems and everything
we should probably "merge" those two gems
Nick Sutterer
@apotonick
@timriley question reg. dry-matcher. so, when i define using Matcher.new that's called the matcher object?
and when i evaluate it, how's that named?
and, what are you doing awake at 7am on a sunny saturday?
Tim Riley
@timriley
Kids :p
Yeah, I guess Matcher.new makes the matcher object, and then you run it with a a "match block" against some kind of value
/me will think about those names a little more
Steve
@dnd
is there a way to get the errors from dry-validation as symbols/keys instead of text sentences? I'm looking to get output like {amount: [:missing, :min_size]} or something like that
Nick Sutterer
@apotonick
@timriley "match block", i just called it handler, but yeah
Martín Fernández
@bilby91
Hello, do I need to require something in order to use Types::Maybe ?
Tim Riley
@timriley
Yeah, it's an "extension" now, @bilby91 - I'm on my phone right now but if you grep the specs for :maybe, you should see how it's done.
Martín Fernández
@bilby91
Perfect! Will check
Thanks @timriley

Is this correct ?

# frozen_string_literal: true
class User < Dry::Struct
  attribute :id, Types::Strict::Int
  attribute :source_url, Types::Strict::String
  attribute :width, Types::Maybe::Float
  attribute :height, Types::Maybe::Float
  attribute :format, Types::Maybe::String
end

I’m getting NameError: Float cannot be autoloaded from an anonymous class or module

Nick Sutterer
@apotonick
@bilby91 did you require the types file?
Tim Riley
@timriley
I've never seen this error. Are you using this inside Rails?
Yeah, you might want to explicitly require the file where you set up the Types module
Nick Sutterer
@apotonick
@timriley how can i know whether or not a matcher has executed a "handler"?
Martín Fernández
@bilby91
My bad, I was missing Strict or Coercible on the Maybe types
I’m working on a rails project
Tim Riley
@timriley
@apotonick how do you mean?
Nick Sutterer
@apotonick
@timriley matcher.(result) #=> no handler was found ? how do i know
add my own handler?
Tim Riley
@timriley
Ahh. Hmm, there no authoritative way to know right now.
Nick Sutterer
@apotonick
@timriley could we add a special return value at some point? not too important right now
Tim Riley
@timriley
Yeah, we could look at something like that.
Nick Sutterer
@apotonick
just designing the Endpoint API for Trailblazer
Tim Riley
@timriley
Another way to do it is to make sure you have enough cases defined to cover all potential inputs
Nick Sutterer
@apotonick
yeah but i'm making it customizable
Tim Riley
@timriley
The marcher won't let you pass a match block that is inexhaustive
Martín Fernández
@bilby91
When using Maybe it is required to add the optional keys on the initializer hash ?
Nick Sutterer
@apotonick
we have a default matcher provided by TRB, and then the user can have another
Tim Riley
@timriley
I.e. It'll require you have at least one of each case
Steve
@dnd
@timriley is there any way to do my question above regarding dry-validation errors?
Nick Sutterer
@apotonick
@dnd we will sort this out in reform soon, the dry-v/errors API
Tim Riley
@timriley
@dnd there should be a way, the error strings are compiled from raw data after all - can you post your question on discuss.dry-rb.org?