These are chat archives for dry-rb/chat
Hi all :)
I have a transaction who call MongoDB and Redis.
What's the best way to test it?
Schemais not going to make any assumptions besides the object being validated quacking like a ruby Hash. JSON of course has a slightly different structure, where keys are always strings. It looks like it may automatically convert strings to symbols. Params is designed to work more directly with the type of structures you would get from an http request. As far as I know there isn't much other documentation besides the link above
Dry::Validation.JSONhere: https://github.com/dry-rb/dry-validation/blob/master/examples/json.rb - but i don’t see in docs. Should i use this type of schema or only
Dry::Validation.Schema. I would like to know about when use one or other.
Dry::Validation.Schemaeverywhere because i am validating plain ruby hashes. I also had not seen the JSON schema until now. it looks like it does some processing on input and symbolizes the names for you so you can define the schema rules using ruby symbols. I would say if you know you're validating JSON or http Params, use those more specifically. I will have to play around to see what kinds of things are actually different about them.
::JSON.parse(request.body.read, symbolize_names: true)as my input and
Dry::Validation.Schemausing symbols to define schema
Dry::Validation.JSONand avoid the
symbolize_namespart. it looks like dry might have some predicates that are customized for JSON if using that schema which is the only other difference i could find quickly