Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Nov 18 00:58
    dteoh starred dry-rb/dry-types
  • Nov 17 21:02
    flash-gordon commented #374
  • Nov 17 21:01

    flash-gordon on master

    Update custom_ci.yml Merge pull request #374 from sk… (compare)

  • Nov 17 21:01
    flash-gordon closed #374
  • Nov 17 20:59
    skryukov opened #374
  • Nov 17 16:42

    flash-gordon on use-immutable-equalizer

    (compare)

  • Nov 17 16:42

    flash-gordon on master

    Use immutable equalizer for all… Merge pull request #373 from dr… (compare)

  • Nov 17 16:42
    flash-gordon closed #373
  • Nov 17 16:38
    flash-gordon opened #373
  • Nov 17 16:38

    flash-gordon on use-immutable-equalizer

    Use immutable equalizer for all… (compare)

  • Nov 17 16:34

    flash-gordon on no-rewrap-for-structs

    (compare)

  • Nov 17 16:34

    flash-gordon on master

    Don't build constructors when c… Merge pull request #371 from dr… (compare)

  • Nov 17 16:34
    flash-gordon closed #371
  • Nov 16 11:28
    marekciupak starred dry-rb/dry-monads
  • Nov 16 07:48
    luizfonseca starred dry-rb/dry-view
  • Nov 15 18:52
    waiting-for-dev commented #114
  • Nov 15 16:06
    businessBoris starred dry-rb/dry-system
  • Nov 15 15:16
    businessBoris starred dry-rb/dry-monads
  • Nov 15 08:22
    gruz0 starred dry-rb/dry-types
  • Nov 14 12:03
    pedrofurtado starred dry-rb/dry-matcher
George Millo
@georgemillo
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
Tim Riley
@timriley
ah, I probably got it wrong, sorry
Tim Riley
@timriley
It’s an interesting question though, the intersection of type specs and each
Ralf Schmitz Bongiolo
@mrbongiolo
Yes, I guess it makes sense to be able to coerce array values in the way that you expressed. Not sure if that would be doable or way to off of what each() proposes
Christian Meier
@mkristian
hi, I am looking for some way to share validation rules between server and javascript client. I wonder if dry-validation can export its 'rules' in one way or the other ?
Andy Holland
@AMHOL
@mkristian I've thought about this a lot in the past, the best solution I could think of was a custom verb like DESCRIBE to build the model representation on start-up, but I think just sticking to server-side validation is the better option
Having said that dry-validation builds an AST, so you could use that to create some representation of the validation predicates
Christian Meier
@mkristian
that sound interesting.
server side validation is easier but with javascript only clients not an option - anymore
Andy Holland
@AMHOL
Not sure what you mean, surely you send your data to the server at some point?