Nikita Shilnikov
Nikita Shilnikov
It's enough to check if `input` is a `Hash` before, otherwise it's a safe transformation.
🤔 Why do you think this is a bug? Is there any example of code working like this: ```ruby optional(:image_attributes).maybe(:hash) do ::Attachments::Schemas::Base.new end ``` ?
@solnic It can be useful, especially there's no established way of providing defaults for deeply nested structures. I would use default types for that under the hood, as in, `required(:op_type).value(Types::Integer.default(0))`....
but `Params::Nil` is already a type so if you want to make work like `"" => Undefined` you'll need to do it explicitly, without default types at all. My suggestion...
I'm not sure if this is a bug or a missing feature but it's an issue in dry-schema so I moved it
It's important to realize that comparing trivial cases is not really representative. It can very well be that any lib gets exponentially slower as rules grow complex.
Something's wrong here ``` dry-schema> params { required(:list).array(Dry.Struct(name: 'string')) }.type_schema.(list: []) => {:list=>{}} ```
@solnic I meant something's wrong with type schema, it converts an empty array to a hash
@pyromaniac 💯 that wasn't planned to work like this :)
no clue. It's possible to create a custom schema type that transforms input keys ```ruby module Types include Dry::Types() FancyHash = Hash.schema({}).with_key_transform { |key| key.gsub('?', '').gsub(' ', '_').to_sym } end...