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
Don't validate fields that were not passed #1184
Conversation
Hi @joesaunderson! |
I can try, there aren't many existing tests though, so not sure where I'll be starting from. |
Yep @Vincz this is a bit beyond my knowledge of this bundle, there's nothing to extend and I'm getting into the internals of the system. |
Hi @Vincz, @joesaunderson I don't understand the need for this change. I our use-case we're creating an order and filling customer data based on the input.
The validation group is then computed based on the value of the But after this change, the Can you explain the use-case benefiting from this change? And do you have an idea how to solve the case I described? |
The use case benefitting this change. Imagine a mutation like so:
Where If you only want to edit some properties of the entity, you can pass only the properties you want to edit. Previously, if you did this, it ran the validation rules for every properly of that entity (or input object in this case) regardless of whether they were passed on not. |
But that way you have to count on the data you're passing down the application. So it's really easy to make a mistake and set data that should not pass the validation. |
Not sure I fully understand your use case so forgive me... But isn't it correct that when not passing the It should only be validated when it's passed (which is when |
Where does the counting element come in to it? This way the data you pass in is validated, the data you don't pass in isn't validated? |
If I set the differentDeliveryAddress = true, the I want to validate the deliveryFirstName regardless if passed in mutation. Now I have to be sure I pass all field even though the schema do not require them, otherwise invalid data may be set |
I understand it better now. Devils advocate... if you're essentially requiring that field when differentDeliveryAddress = true, shouldn't your application ensure it's always passed too? @Vincz suggested this behaviour could be a config setting, so maybe that could be an option?
|
Hi @grossmannmartin, @joesaunderson |
I should have some time to look at it Tuesday. Can you point me in the direction of where config is used in other places? |
Hi, thanks for understanding and the dialog :) From my point of view, the original behavior is better as a default, because otherwise the rest of the application has to know what was passed as arguments and it's a behavior that already was. If necessary, I can make some time at the end of the week... sooner is not possible for me, sorry |
@Vincz @grossmannmartin I had a brief go at this today. It adds a new config option I tried to add it to the field level too (under I believe it puts us in a good place for full / partial validation. |
This fixes the validation rules so that when passing a partial input object, only the fields passed are validated.