Replies: 4 comments
-
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. |
Beta Was this translation helpful? Give feedback.
-
I went for @alganet's idea, and I decided to convert this into a discussion. Changing the whole validator to optional might also make things weird, especially when dealing with nested validators. Imagine this all this being optional. v::key('email', v::email())->assert($input); If everything is optional here, you're saying that Personally, I prefer to make things more explicit. Still, I understand that the syntax In version 3.0, I will introduce prefixes. We could have a prefix for
I'm leaning more toward option 3, |
Beta Was this translation helpful? Give feedback.
-
I've created a merge requests with that and other prefixes. I would appreciate if you could give some feedback! #1453 |
Beta Was this translation helpful? Give feedback.
-
It's been a while that there are no comments here. I'm closing this discussion for now 🐼 |
Beta Was this translation helpful? Give feedback.
-
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.
Beta Was this translation helpful? Give feedback.
All reactions