Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Feb 26 16:22
    karpinovsky starred dry-rb/dry-auto_inject
  • Feb 26 16:22
    karpinovsky starred dry-rb/dry-container
  • Feb 26 16:22
    karpinovsky starred dry-rb/dry-matcher
  • Feb 26 16:22
    karpinovsky starred dry-rb/dry-monads
  • Feb 26 16:22
    karpinovsky starred dry-rb/dry-initializer
  • Feb 26 16:21
    karpinovsky starred dry-rb/dry-system
  • Feb 26 16:21
    karpinovsky starred dry-rb/dry-types
  • Feb 26 14:03
    solnic commented #143
  • Feb 26 13:19
    davydovanton commented #143
  • Feb 26 13:04
    solnic commented #143
  • Feb 25 23:58
    davydovanton review_requested #143
  • Feb 25 23:56
    davydovanton synchronize #143
  • Feb 25 23:56

    davydovanton on strategies-fail

    Fix error with mutation of froz… (compare)

  • Feb 25 22:40
    davydovanton review_requested #143
  • Feb 25 22:40
    davydovanton review_requested #143
  • Feb 25 22:40
    davydovanton assigned #143
  • Feb 25 22:40
    davydovanton opened #143
  • Feb 25 22:40
    davydovanton review_requested #143
  • Feb 25 22:40
    davydovanton labeled #143
  • Feb 25 22:34

    davydovanton on strategies-fail

    Fix error with mutation of froz… (compare)

Ramon Tayag
@ramontayag
@solnic I want to add something to the readme about constructor_type to the readme. As far as I can see, there are these types: :strict, :permissive, and :schema. I guess you meant that it is :strict by default, but what is the difference with the latter two?
Let me check dry-types first
Ramon Tayag
@ramontayag
There are certain schemas in the codebase of dry-struct that can't be found in http://dry-rb.org/gems/dry-types/hash-schemas/ that
Ramon Tayag
@ramontayag
For dry-struct, what is the recommended way of creating setters?
Ramon Tayag
@ramontayag
@jdickey cool :)
Piotr Solnica
@solnic
@ramontayag the recommend way is to not use setters :)
Piotr Solnica
@solnic
@ramontayag there’s a WIP PR which will add more docs about it dry-rb/dry-rb.org#104
Ramon Tayag
@ramontayag
@solnic ok cool I can discard my changes then! How would you go about replacing virtus with the dry gems? Would you recommend doing so?
Hannes Nevalainen
@kwando
dry-validation is freaking awesome! xD
Steve
@dnd
@timriley, @solnic I posted my question from the other day on the discussion board, but haven't gotten any traction on it. Any idea if there is a way to easily do this currently, or where I could start looking to make it possible? https://discuss.dry-rb.org/t/get-keys-instead-of-sentences-for-validation-errors/150/1
Piotr Solnica
@solnic
@dnd hey, I’ll be replying to posts later today. I’ve been busy with rom-sql new release lately
Steve
@dnd
cool, thanks
Lucas Hosseini
@beauby
Any specific reason why no built-in predicates on min/max length of strings in dry-validation?
Fran Worley
@fran-worley
@beauby there are built in predicates. min_size? And max_size? Work on anything that responds to size.
Lucas Hosseini
@beauby
Hmm some examples seem to imply that the _size? predicates work on string, but the doc says it is valid for arrays only
Fran Worley
@fran-worley
Take a look here to see all built in predicates and the code behind them: https://github.com/dry-rb/dry-logic/blob/master/lib/dry/logic/predicates.rb
Lucas Hosseini
@beauby
@fran-worley Right – yeah, that was my source of information, but as you can see, it explicitly talks only about arrays
I’ll issue a PR
Fran Worley
@fran-worley
Good spot on the docs and thanks in advance for the PR.
Piotr Solnica
@solnic
@kwando haha, is it? :D
@dnd re virtus, you need dry-struct + attr_writer
then, assuming your virtus models are relatively simple, this should be easy
just remember that dry-struct uses types that don't match virtus coercion logic
so ie if you use input from http params, you would have to use Types::Form::* types for your attributes
Steve
@dnd
@solnic I think someone else was looking for that information.
I think @ramontayag was?
I'm just here for the dry-validation errors question. :)
Piotr Solnica
@solnic
ugh sorry about that
@ramontayag see above re virtus ^^
Ramon Tayag
@ramontayag
I see - thanks @solnic
Ramon Tayag
@ramontayag

Given

schema = Dry::Validation.Schema do
  required(:age)
end

I expect to see an error that the key is missing when I do schema.({}).errors. Am I understanding right?

Soumya Ray
@soumyaray

I'm playing around with dry-monads for the first time, and I'm not sure if I'm using it as expected. Here's an example of a simple service object that I'm trying to make using it:

class FindGroup
  extend Dry::Monads::Either::Mixin

  def self.call(params)
    Right(params[:id]).bind do |group_id|
      group = Group.find(id: group_id)
      if group
        Right(group)
      else
        Left(Error.new(:not_found, 'Group not found'))
      end
    end
  end
end

Does this look right? Should I be using dry-transactions or something else over this?

The thing that is bothering me most right now is that this style of coding very quickly becomes hard to read with more complex examples.

Nikita Shilnikov
@flash-gordon
@soumyaray more or less, could be simplified ```
  def self.call(params)
    group = Group.find(id: params[:group_id])
    if group
      Right(group)
    else
      Left(Error.new(:not_found, 'Group not found'))
    end
  end
monads are just some sort of containers
they are giving you a unified interface for dealing with things, but nothing more
dry-transaction is an example of what you can do next by gluing your monads together :)
@soumyaray we often recommend this video to watch http://fsharpforfunandprofit.com/rop/
Soumya Ray
@soumyaray

@flash-gordon i agree! i was a influenced by the documentation of dry-monads, which has this:

    i = Integer(input)

    Right(i).bind do |value|
      if value > 1
        Right(value + 3)
      else
        Left("value was less than 1")
      end
    end.bind do |value|
      if value % 2 == 0
        Right(value * 2)
      else
        Left("value was not even")
      end
    end

I'll sit and give that video a watch. Like with many things that are new to Ruby (concurrency paradigms, monads, etc.), it really hard for those of use who haven't seen those used in another language.

Many thanks for your input!
Nikita Shilnikov
@flash-gordon
yeah, docs can be too brief or shallow for giving you a sense of what's this all about
Nick Sutterer
@apotonick
@timriley you around?
i'm trying to integrate your auto_inject code
Nick Sutterer
@apotonick
...and i'm successful! i want you to commit that file, though
Martin Komara
@scare21410
Hey guys, is there any reason why TRUE_VALUES miss Y in Dry::Types::Coercions::Form? There are 1 on On ON t true True TRUE T y yes Yes YES and I think Y should be there too. Same for N and FALSE_VALUES
Tim Riley
@timriley
@apotonick commit the file? I don't think it'd make sense to ship with dry-auto_inject itself, since its such a specialized use case. Could you ship it as part of your operations gem?
@scare21410 I'm sure it's just an oversight - submit a PR and I'm sure we'll pull it in :)
Piotr Solnica
@solnic
:+1: for Y and N
Fran Worley
@fran-worley
@solnic :+1: from me too for what it's worth!
Piotr Solnica
@solnic
we’re the guardians of the TRUE_VALUES