These are chat archives for dry-rb/chat

Jun 2016
Tanner Donovan
Jun 05 2016 02:00
I’ve just started playing around with Crystal and wanted to get some thoughts on porting some of the dry-rb gems .i.g.
could shards be part of dry-rb or would there be any objection to spin-off a dry-cr
Gilbert Komin
Jun 05 2016 06:07
Hi, everyone. I have small problem with form validation. I have optional array which can be empty or not - and when I want to use optional(:employee_attribiutes).maybe(:array?) - in test when I send empty params (nil) for this array - I’ve got a error: NoMethodError: undefined method `[]' for nil:NilClass. What I did wrong? :)
Tim Riley
Jun 05 2016 06:28
@myf9000 that test is not actually a fathful replication of a form post, since they can never send nil - always an empty string in cases like that. If you pass an empty string, does it work?
The dry-validation form schemas are meant to handle input from rack-processed forms posts.
Gilbert Komin
Jun 05 2016 20:17

Thanks for answer but is any possibility to do something like that :

optional(:employee_attributes).maybe(:array?).each do

When I have in params employee_attributes I want to check its attributes, and when I have "" or nil or [] - return true. I tried to write my custom rule but it doesn’t work for array.


      rule(present_employee_attributes: [:employee_attributes]) do |attributes|

      configure do
        def is_present?(attributes)
          return true if attributes.empty?

What I'm doing wrong?

Thanks to @flash-gordon, @mrbongiolo, @joevandyk and @ttdonovan!
Piotr Solnica
Jun 05 2016 23:01
@myf9000 maybe + each is not supported yet, I'll be adding this for 0.8.0 release
btw use schema inside each, nested key syntax will be gone in 0.8.0