Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 15 19:07
    jjw starred dry-rb/dry-types
  • Dec 15 18:13

    flash-gordon on master

    Remove unreachable method (compare)

  • Dec 15 18:11

    flash-gordon on master

    Remove Dry::Types.type_keys It… (compare)

  • Dec 15 18:09

    flash-gordon on master

    Remove unreachable code (compare)

  • Dec 15 18:04

    flash-gordon on master

    Coverage for function.rb (compare)

  • Dec 15 17:15

    flash-gordon on fix-maybe-call-safe

    (compare)

  • Dec 15 17:15

    flash-gordon on master

    Fix behavior of Maybe#call_safe… Merge pull request #380 from dr… (compare)

  • Dec 15 17:15
    flash-gordon closed #380
  • Dec 15 17:13
    flash-gordon synchronize #380
  • Dec 15 17:13

    flash-gordon on fix-maybe-call-safe

    Fix behavior of Maybe#call_safe… (compare)

  • Dec 15 17:12
    flash-gordon opened #380
  • Dec 15 17:11

    flash-gordon on fix-maybe-call-safe

    Fix behavior of Maybe#call_safe… (compare)

  • Dec 15 17:00

    flash-gordon on fix-maybe-try

    (compare)

  • Dec 15 17:00

    flash-gordon on master

    Fix behavior of Types::Maybe#try Merge pull request #379 from dr… (compare)

  • Dec 15 17:00
    flash-gordon closed #379
  • Dec 15 15:09

    flash-gordon on master

    Fix typo Merge pull request #67 from gru… (compare)

  • Dec 15 15:09
    flash-gordon closed #67
  • Dec 15 14:43
    flash-gordon opened #379
  • Dec 15 14:43

    flash-gordon on fix-maybe-try

    Fix behavior of Types::Maybe#try (compare)

  • Dec 15 14:30

    flash-gordon on master

    Lax coverage (compare)

alexeymoshkin
@alexeymoshkin
@cdennl thanks, I will try
Martín Fernández
@bilby91
This message was deleted
Martín Fernández
@bilby91
It it possible to use AutoInject in a rails concern ?
Tim Riley
@timriley
You really want to include it in a class, not in another module.
Ernest Bursa
@swistaczek
Hey guys, did some one tried integrating dry-system with existing rails app?
I would be happy if anyone could share an example, this will be great for boosting my lunch time to dry-rb concept :)
Tim Riley
@timriley
I'm not sure if anyone has an app they can share for this, @swistaczek, but solnic did write a dry-system-rails gem to provide s railtie, so it should be possible.
Martín Fernández
@bilby91
Hey, I’m willing to help on the dry-system for rails too!
George Millo
@georgemillo
Can someone explain to me the difference between hints, errors, and messages in dry-v?
looks like messages = hints + errors, amirite?
but what's the difference between hints and errors?
Christopher Dennl-Ortega Arrieta
@cdennl
@georgemillo one is all messages that can happen, and the other is only messages for errors that actually happened
Martín Fernández
@bilby91
Should I expect the correct coercion for this validations ? The input can be a string like “120” or “1.2"
Dry::Validation.Form do
      optional(:width).maybe { float? | int? }
      optional(:height).maybe { float? | int? }
end
George Millo
@georgemillo
@cdennl I thought so, but there seem to be some inconsistencies there
I'll move it to the discussion forums
Sergey Kukunin
@Kukunin
is there any reason behind the prevention to overwrite attributes in inherited dry-struct ?
currently it has check, that attribute is already defined, and crashes
Nikita Shilnikov
@flash-gordon
@Kukunin I doubt there is any strong reason for this, pls open an issue, will see what Piotr and John will say. I'd personally :+1: for removing this restriction
Tim Riley
@timriley
Yeah, it'd made sense to me to allow attributes to be redefined.
Alexey Zapparov
@ixti
Hi all. Is there a way to define custom coercion type for schema?
I have an endpoint that accepts list of ids separated with comma, so i want to do something like:
schema = Dry::Validation.Form do
  required(:ids) { comma_separated_list? }
end

schema.call({ "ids" => "1,2,3" })["ids"] # => ["1", "2", "3"]
Tim Riley
@timriley
@ixti Sounds like something that type specs (http://dry-rb.org/gems/dry-validation/type-specs/) and a custom type would help you achieve
e.g. something like required(:ids, Types::MyCommaSeparatedList).filled(:array?)
where that MyCommaSeparatedList type would accept string input and coerce it into an array
Alexey Zapparov
@ixti
@timriley mm, yeah. that will definitely work for me indeed. Thanks!
Alexey Zapparov
@ixti
Was it considered change API a bit? like instead of Dry::Validation.Form it would be better to write Dry::Validation::Form.describe imho :D
I'm OK with current API. It just looks a bit awkward to me :D
As awkward as when I see someone uses :: to call method
Christian
@bakku
In dry-validation is there a difference between required(:name) and required(:name).filled?
Andy Holland
@AMHOL
required(:name) means the hash key is required, .filled? means the value must be non-blank
Ralf Schmitz Bongiolo
@mrbongiolo
Is there a way to coerce array values with dry-validation?
Tim Riley
@timriley
@mrbongiolo what sort of thing would you like to achieve?
Ralf Schmitz Bongiolo
@mrbongiolo
@timriley Actually I have a form that sends IDs, but as string, I would like to coerce them to Integer, something like:
optional(:my_ids, [:nil, :array]).each([:nil, :int], :int?)
Tim Riley
@timriley
OK cool. And is this a Dry::Validation.Form schema?
Fran Worley
@fran-worley
@mrbongiolo I use Types::Form::Array.member(Types::Form::Int) works perfectly in my Reform form to do exactly as you describe
Ralf Schmitz Bongiolo
@mrbongiolo
Thanks @fran-worley I'll try this out :)
It worked like a charm!!! Thanks for the help, I had forgotten about the member key on Dry::Types
Tim Riley
@timriley
Can we see your final result, @mrbongiolo? :)
Thanks @fran-worley :)
Ralf Schmitz Bongiolo
@mrbongiolo
Sure @timriley, here it is:
# first I defined my custom Dry Type
module MyApp
  module Types
    include Dry::Types.module
    ArrayOfInts = Types::Form::Array.member(Types::Form::Int)
  end
end

# Then I use it on my Schema
optional(:my_ids, [:nil, MyApp::Types::ArrayOfInts]).each(:int?)
Tim Riley
@timriley
right, very nice :)
Ralf Schmitz Bongiolo
@mrbongiolo
Is there an easy way to say that the schema should be valid only if one specific key is given and none of the others, or only some of the others? Or I would need to list all the other keys on a custom rule?
Tim Riley
@timriley
just on the schema still, another way could be like this:
optional(:my_ids, [:nil, :array]).each([:nil, Types::Form::Int], :int?)
or something like that, using dry-types’ coercing form types
if you wanted to avoid creating an “ArrayOfInts” type just for this purpose
That’s why I was asking whether it was .Form schema, I was wondering if/how that worked with the new type specs
Ralf Schmitz Bongiolo
@mrbongiolo
@timriley so each accept a type as first argument?
I'm using Dry::Validation.Form with type_spec = true on the configs
I've tried your suggestions, but then I get this error: +nil+ is not a valid predicate name