-
-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it possible to configure new Hash constructor type #180
Comments
We're definitely not going to add more hash schema types, or an API for configuring them, especially if it's related to validating input, as data validation is meant to by handled by dry-validation. Schema types that we have were added to cover a couple, very specific use-cases, that are related to building structs using data from specific sources (like a database, or JSON). From what I've seen, people keep asking about more relaxed approach to setting defaults, and it's always related to testing, it seems like that's your situation as well, right? |
In my case it is a need in Domain layer. I have an Value Object to represent answers on pre-defined questions. There are 12 of such questions. All answers are optional. All answers are So I decided, that Hash with I don't want an array of question, because there may be duplicates, and it's more complicated. Currently, the most representative way is BTW, feel free to close this issue |
btw, #113 would work here as well
|
We implemented support for flexible yet simple schemas. #113 remains open for now but I have a feeling we'll implement it as well before 1.0 is out. |
Currently
Types::Hash
has 6 pre-defined constructor types, with own properties.But they aren't enough for all purposes, e.g. there is an issue dry-rb/dry-struct#32 for
dry-struct
(created by me).Now, I've got another case, where I want hash to allow defined keys absence, but deny any extra keys.
Instead of defining new 7th constructor type with confusing name, maybe it's good to configure contructor types alone?
Something like:
The text was updated successfully, but these errors were encountered: