Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 00:14
    thekuwayama starred dry-rb/dry-monads
  • Dec 11 09:29
    blasterun starred dry-rb/dry-monads
  • Dec 11 08:34
    flash-gordon closed #115
  • Dec 11 08:34
    flash-gordon commented #115
  • Dec 11 08:31

    flash-gordon on v1.3.3

    (compare)

  • Dec 11 08:30

    flash-gordon on master

    Bump version to 1.3.3 (compare)

  • Dec 11 08:30

    flash-gordon on master

    Update CHANGELOG (compare)

  • Dec 10 23:46
    johnmaxwell commented #116
  • Dec 10 21:54

    flash-gordon on master

    Halt with mutable backtrace Ex… Merge pull request #116 from jo… (compare)

  • Dec 10 21:54
    flash-gordon closed #116
  • Dec 10 21:54
    flash-gordon commented #116
  • Dec 10 21:49
    johnmaxwell commented #116
  • Dec 10 21:47
    johnmaxwell commented #116
  • Dec 10 21:43
    johnmaxwell commented #116
  • Dec 10 21:39
    johnmaxwell commented #116
  • Dec 10 21:31
    johnmaxwell commented #116
  • Dec 10 21:22
    flash-gordon commented #116
  • Dec 10 19:41
    johnmaxwell opened #116
  • Dec 10 19:36
  • Dec 10 10:24
    krautcat starred dry-rb/dry-view
Lucas Hosseini
@beauby
:+1:
alexeymoshkin
@alexeymoshkin

Hi there! How can I change property value, when form.validate depending on value of other property in this form
For example:

property :amount
property :type

if type == 'negative'
  amount = 0 - amount
end

Any solution?

Christopher Dennl-Ortega Arrieta
@cdennl
@alexeymoshkin high level rules, look in the docs
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