-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat: [Validation] add field_exists
rule
#8123
feat: [Validation] add field_exists
rule
#8123
Conversation
?string $error = null, | ||
?string $field = null | ||
): bool { | ||
return array_key_exists($field, $data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, we need to handle the key with dot array syntax?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I'm afraid so. See required_without
above. May be worth having a private method for $data
transformations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see your next PR - much better solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, done.
673ff74
to
eda462a
Compare
I believe we would also need versions
|
Really? |
Sorry, I forgot about this one. Example... an API with a custom payload? Some optional fields depend on selected parameters. They're not required though. I think I saw a request like this a long time ago, but I can't find it now. |
I think we can use
If it is not required, then it is okay that the key does not exists in the data. If it is required, and the value may be null, empty string, then we need |
f24c53a
to
cfa4fa1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I think starting here makes sense and if we find need for additional related rules they can follow.
Needs #8131Description
For #8006
Checklist: