These are chat archives for dry-rb/chat

13th
Jul 2017
Pierpaolo Frasa
@Fryie
Jul 13 2017 12:19
@cllns i guess that works fine. I have been putting schema definitions into constants, but no difference really
Rafael George
@cored
Jul 13 2017 15:33
hi
dry-types, dry-struct question
this is failing for me Dry::Types["array"].member(Dry::Types::Coercible::String)
can't find Coercible
Nikita Shilnikov
@flash-gordon
Jul 13 2017 15:38
@cored must be Dry::Types['array'].member(Dry::Types['coercible.string'])^
Rafael George
@cored
Jul 13 2017 15:38
thanks
@flash-gordon
I'm getting a different error which is odd for me
I'm passing the field that dry struct is complaining about
Nikita Shilnikov
@flash-gordon
Jul 13 2017 15:45
@cored you have different spelling for retail_fulfillment_order_id :)
Rafael George
@cored
Jul 13 2017 15:45
oh man
I must be blind
maybe I need more coffee
thanks again @flash-gordon
Nikita Shilnikov
@flash-gordon
Jul 13 2017 15:46
sure :)
Rafael George
@cored
Jul 13 2017 15:55
is there a way for me to define a type base on a hash @flash-gordon
in my input something like value: { key: value }
how can I specified that as an attribute for my struct? unless I need to also define another inner struct representing that as a type ?
Nikita Shilnikov
@flash-gordon
Jul 13 2017 15:56
hash schemas are used by structs under the hood
Rafael George
@cored
Jul 13 2017 15:57
oh I see
is a hash type
thanks again
Roman
@sigmen
Jul 13 2017 16:21

Hi. Can u help me pls, i got this error

undefined method `assert_valid_value' for #<Dry::Types::Definition primitive=Integer options={} meta={}>

when i use dry-types with rails (4.2.6/5.1.2). I was try install dry-types-rails, but it doesnt work. I didnt find info in google about this issue.

Nikita Shilnikov
@flash-gordon
Jul 13 2017 16:48
@sigmen I don't know what's dry-types-rails but you most probably don't need it. There were some issues with structs in rails and hot reloading and AFAIK they gone. I'd try to use dry-types as is
Sean Collins
@cllns
Jul 13 2017 18:44
@Fryie Ah, thanks! I guess you can freeze the Schema if it's a constant?
Rafael George
@cored
Jul 13 2017 18:51
looks like I can't catch Dry::Types::MissingKey exception
nvm, was trying to catch the wrong exception
Rafael George
@cored
Jul 13 2017 19:03
can I change the error message thrown by dry types errors
like I want it to say something diferent than 'missing key <key>'
Nikita Shilnikov
@flash-gordon
Jul 13 2017 19:06
you don't need to handle dry-struct exceptions
Sean Collins
@cllns
Jul 13 2017 19:06
@cored you can for dry-validation http://dry-rb.org/gems/dry-validation/error-messages/
Nikita Shilnikov
@flash-gordon
Jul 13 2017 19:07
@cored structs are supposed to be valid, if they throw exceptions then these exceptions should be treated as truly exceptional events
Rafael George
@cored
Jul 13 2017 19:10
@cllns yes, was thinking now on using dry-validation
@flash-gordon make sense
I have mix feelings due to my current code base instead of the gems
this is a "service object" but they use ActiveController::Parameters
to extract valid parameters so then that get past to the service that I wrote that already uses value objects with dry-types
so I guess I could add dry-validation at the higher level to handle the validation of the data
Sean Collins
@cllns
Jul 13 2017 19:16
mhm! putting validation as close to input as possible is nice. Rails doesn't do this, but Hanami does :)
Rafael George
@cored
Jul 13 2017 19:19
yes, I would like to switch to hanami
but first I need to separate all the business logic from framework details
my current approach is just to allow dry-rb stuffs in my business logic
and that's it, mainly because is light weight
Andriy Tyurnikov
@andriytyurnikov
Jul 13 2017 22:35
@solnic , could you tell more about your ideas of possible adding generative capabilities to dry-type or dry-validation? do you have any concerns about present boundaries between dry-validation/dry-types/dry-struct/dry-logic ?