You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whilst reviewing the documentation it seems having everything set as 'optional' was the default in older releases - I'm finding in my own use cases is that this would be preferred, as wrapping v::optional around almost every validator is way too verbose.
Are there plans to add a setting to make things optional by default? If there are not, what would be the pref. way to extend the validator to make such a setting? Eg. v::allOptional(true);
Somewhat related - the documentation for validating object attributes does not mention the (ironically optional) 'mandatory' boolean.
I would like more feedback before implementing this. I was behind the decision to make everything optional in older releases, as I prefer that approach as well, but it seems to confuse most of the users.
This behavior "lives" in each rule, and it is not something central. It is more a mindset than a piece of code. Some rules still have remains of being optional (like the attribute and key you mentioned). It is very likely that we're going to make them mandatory by default in future releases.
To support both approaches, we would need a different Validatable interface, with some method to be implemented by all rules that defines the behavior when optionals are turned on. It might get complicated.
I'll keep this open for a while, and I might convert it to a discussion in GitHub discussions so it can be a long-lived theme.
Activity
alganet commentedon Feb 20, 2023
I would like more feedback before implementing this. I was behind the decision to make everything optional in older releases, as I prefer that approach as well, but it seems to confuse most of the users.
This behavior "lives" in each rule, and it is not something central. It is more a mindset than a piece of code. Some rules still have remains of being optional (like the attribute and key you mentioned). It is very likely that we're going to make them mandatory by default in future releases.
To support both approaches, we would need a different Validatable interface, with some method to be implemented by all rules that defines the behavior when optionals are turned on. It might get complicated.
I'll keep this open for a while, and I might convert it to a discussion in GitHub discussions so it can be a long-lived theme.