Replies: 1 comment 2 replies
-
The use case you and the referenced proposal give, require additional validation. the user_id must exist, the email must be a valid e-mail. Do you have a use case where this is actually useful? I can think of an API-token, but you can already tell if they are there or not using https://laravel.com/docs/master/requests#determining-if-input-is-present |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Following up on the same proposal on laravel/ideas#2260
required
validation rule is the most popular rule that I have seen and this is used often by developers. This feature adds a newrequired
method to Request object as a shorthand to "validate" and return required fields.The above snippet validates both
user_id
andemail
and return an array that is similar to validated() method ofFormRequest
object.The benefit is that for a little validation that only requires required rule without creating a Form request or writing custom validation.
Proposal for better naming instead of
required
is welcomed.Beta Was this translation helpful? Give feedback.
All reactions