These are chat archives for dry-rb/chat

28th
Aug 2017
what are the thoughts regarding this? Is there a nicer way?
Tim Riley
@timriley
Aug 28 2017 05:43
@siassaj I guess that’s fine. I’d assign the schema to a constant nested inside the struct class definition though, so you don’t need to rebuild the schema for every struct instance you have
though tbh this feels like you need an Address#complete? method
which probably doesn’t need the overkill of a whole dry-v schema
especially since you’re not going to be using any of the other features it ofers, like error message, etc., you’re just returning a true/false
Joshua Hansen
@binarypaladin
Aug 28 2017 21:35
@timriley Before I go make an issue, as of the latest version of dry-validations:
schema = Dry::Validation.Schema { required(:name).filled(:str?) }
r = schema.(name: 'John Doe', occupation: 'Placeholder Person')
r.output => {:name=>"John Doe", :occupation=>"Placeholder Person"}

form = Dry::Validation.Form { required(:name).filled(:str?) }
r = form.(name: 'John Doe', occupation: 'Placeholder Person')
r.output => {:name=>"John Doe"}
Is that the expected behavior or is that a bug?
Tim Riley
@timriley
Aug 28 2017 22:51
@binarypaladin Pretty sure that’s intended behaviour. Form schemas are meant to strip extraneous input.
That said, I could see it being a useful behaviour for regular schemas too.