[dry-struct] attributes ending with a question mark


We have a legacy JSON that gets wrapped with dry-struct instances. Some of the keys of said JSON end with a question mark, e.g. last_minute? This was all working fine before, but I just bumped dry-struct from 0.6 to 1.0 and noticed it now crashes with NoMethodError: undefined methodlast_minute?’` I didn’t find anything in Changelog so I figured I’d ask here if that’s a regression or if that was never supposed to be supported.

Actually, it was done on purpose. dry-types now has syntax for defining omittable keys by appending ?. dry-struct works the same way for consistency. I didn’t implement a workaround for keys ending with ? because it wasn’t clear this use case even exists in real life. Now few months later, it seems it does exist so feel free to submit a feature request to dry-struct, I’ll try to find a reasonable method.

1 Like

Thank you @flash-gordon, but given what you said it might become confusing if we add this feature so let’s leave it as is. We can always use transform_keys to remove the ? :slight_smile: