Skip to content

Conversation

@bvisness
Copy link

exists can now accept an array of keys to check for existence.

@shadowhand
Copy link
Contributor

What would be the purpose of this? As compared to:

$subset = expect($array, $keys);

Generally when working with multiple keys the ultimate need is to capture a known hash of values and pass that on somewhere else. Can you provide an example of how you would use this?

@bvisness
Copy link
Author

@shadowhand I was making a REST endpoint and wanted to check that all the required fields existed in $input. In that case expect didn't really make sense because I don't want any default values to be used.

@bvisness
Copy link
Author

(I ended up using array_diff_key anyway so I could show the user what fields they were missing...but that's beside the point. 😛 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants