Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
  • Apr 05 17:01
    emaraschio starred dry-rb/dry-monitor
  • Apr 04 15:38
    nepalez closed #74
  • Apr 04 15:38
    nepalez commented #74
  • Apr 04 10:40
    qortex commented #400
  • Apr 04 08:47
    flash-gordon closed #400
  • Apr 04 08:47
    flash-gordon commented #400
  • Apr 03 21:18
    qortex starred dry-rb/dry-types
  • Apr 03 21:14
    qortex edited #400
  • Apr 03 21:14
    qortex labeled #400
  • Apr 03 21:14
    qortex opened #400
  • Apr 03 19:18
    landongrindheim commented #74
  • Apr 02 19:47
    kamilski81 starred dry-rb/dry-monads
  • Apr 02 17:26
    waleedasif322 starred dry-rb/dry-types
  • Apr 02 14:59
    sskylar starred dry-rb/dry-monads
  • Apr 02 13:51
    kirin121 starred dry-rb/dry-container
  • Apr 02 10:56

    davydovanton on performance-improvements-for-rack-monitorring


  • Apr 02 10:55

    davydovanton on master

    Improve memory allocation for R… Merge pull request #34 from dry… (compare)

  • Apr 02 10:55
    davydovanton closed #34
  • Apr 02 02:25
    DaiAoki starred dry-rb/dry-types
  • Apr 01 14:39
    davydovanton commented #34
Sergey Kukunin
btw, those are really cool changes to API of monads
Nikita Shilnikov
Thanks, it took me a while :)
Sam Stickland
Is Types::Form::DateTime supposed to be able to parse multipart form values? i.e start_time(1i), start_time(2i) etc
Adam Davies
Not sure but I
Juanma Cervera
Joe Van Dyk
i have Status = Types::String.enum('draft', 'published', 'deleted'). What's the best way to use that in a validation rule?
i tried required(:status, Status) but that didn't seem to work
(i tried enabling type_specs as well)
Nikita Shilnikov
@joevandyk this what works for me
        Action = Types::Strict::String.enum(*%w[publish update])

        Schema = Dry::Validation.Form do
          configure do
            config.type_specs = true

          required(:action, :string).filled(Action)
Joe Van Dyk
@flash-gordon thanks, that works
@flash-gordon say action is allowed to be nil or empty string, and if it is you want to default to 'publish'. how would you do that?
Nikita Shilnikov
dry-v doesn't handle defaults because it only validates data, so would go with { **defaults, **data }
Joe Van Dyk
@flash-gordon i'm not familiar with that syntax :)
Nikita Shilnikov
ahh, yes, this time plain merge will work better
Joe Van Dyk
i'm assuming there's a way to get dry-v to pre-process that sort of thing and set a default?
Nikita Shilnikov
well, didn't see that :) you can then check for nil in a constructor block, right?
Piotr Macuk

Hi. First of all thank you for great dry-rb gems. Dry-v is awesome! :) I have a problem. I would like to build form schema where some fields are known and some other fields should be dynamically created. I thought that I use Form.with(custom_struct: custom_struct).(params) with option within configure block [like here: http://dry-rb.org/gems/dry-validation/custom-validation-blocks/] but it doesn't work. I cannot use custom_struct inside the schema definition:

Form = Dry::Validation.Form do
  configure do
    option :custom_struct


  optional(:custom).schema do
    # error: "undefined method `each' for #<UnboundMethod:0x007f91b9978608> (NoMethodError)"
    custom_struct.each do |element|

I've found this topic [https://discuss.dry-rb.org/t/build-dry-validations-dynamically/164] in the forum but need some examples. Could you help me somehow? Thanks!

Sergey Kukunin
is there a way to inherit form schema? I found I can pass basic schema via constructor Dry::Validation.Form(BaseSchema), but it requires a class there
John Backus
I've been working on a tool for checking the correctness of YARD docs and I've been using Dry::Types as my sample library. Figured I would share here :P https://github.com/backus/yardcheck
I also use Dry::Types as an example in the readme
Nikita Shilnikov
@backus :+1:
John Backus
It has been something I've wanted for a long time haha
Every time a co-worker of mine is like "I don't like documentation because it goes stale"
I'm like why is there not a tool to check
Tool is still rough around the edges but it is already very useful
John Backus
Also I have a super pedantic branch I've been working on which fixes some of these documentation things I found while testing the tool
Will PR eventually
I suggested adding a Dry::Types::Type so that a ton of the params and returns didn't have to be like
# @return [Constrained, Definition, Sum, Safe]
Nikita Shilnikov
ahh, right, this makes sense
Joe Van Dyk
How do you guys typically structure your interactors/use cases, entities/value objects, etc?
Like we have a process that wants to ensure a card is charged. And another one that wants to check to see if a shipment is late. And another one that generates all types of reports.
Jeff Dickey
@joevandyk well, my own personal take on that would be that your first two sound like discrete use cases operating on orders, payment methods (associated with customers), and shipments (with due-date attributes); your last "all types of reports" is probably a collection of different, related use cases that each may involve different entities for input depending on the reports you're generating. That's just my take, though, without actually knowing anything about your code or domain. Work from the domain to build bounded contexts, and then inward from there
Aaron Burrow
How do I tell if my dry-validation failed or succeeded?
Do I have to look at the error messages?
Or is there some method that will give me a boolean result.
success? maybe
Tim Riley
@burrows-labs yep, success?
David Strauß
Good morning folks! Is there a way / interface to get all defined keys from a dry-validations schema? Currently I have a little duplication going on so I want to use the schema as source of truth:
require_relative '../../common/command'

class StartProjectCommand
  include Command

  schema do

  attributes :project_id
  attributes :short_name
  attributes :name
Alexey Zapparov
is it possible to silently overwrite previously defined attributes of dry-struct?
hanami uses code reloading in development console... which leads to Dry::Struct::RepeatedAttributeError for me
Hannes Nevalainen
Oskar Szrajer
I just wondering, why require(:foo).fillled(:int?) is valid for float, for exmaple (123.123) (just convert float to int in return but do not raise error?)
it doesn't feel right
Nikita Shilnikov
@gotar for me it's not
Dry::Validation.Schema { required(:foo).value(:int?) }.(foo: 123.123)
 => #<Dry::Validation::Result output={:foo=>123.123} errors={:foo=>["must be an integer"]}>