Skip to content
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

Add array().assertItem(). Closes #1656 #1659

Merged
merged 1 commit into from
Nov 24, 2018
Merged

Conversation

erquhart
Copy link
Contributor

@erquhart erquhart commented Nov 21, 2018

See #1656 for use case.

@Marsup recommended creating an array().includes() method, but Joi already has an "includes" concept for arrays via array().items() and it's associated error messages. The target functionality more closely resembles object().assert(), except for array items, and as a supplement to array().items().

array().assertItem() felt the most self explanatory. Feedback welcome.

@Marsup Marsup self-assigned this Nov 24, 2018
@Marsup Marsup added the feature New functionality or improvement label Nov 24, 2018
@Marsup Marsup added this to the 14.2.0 milestone Nov 24, 2018
@Marsup
Copy link
Collaborator

Marsup commented Nov 24, 2018

I was thinking about native Array.includes() when suggesting that, didn't realize it was already taken. I'm going to go for has like Set's method then. Thanks for that, I'm going to make some minor changes after the merge.

@Marsup Marsup merged commit 354f6fa into hapijs:master Nov 24, 2018
Marsup added a commit that referenced this pull request Nov 24, 2018
@erquhart erquhart deleted the assert-item branch November 26, 2018 15:14
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New functionality or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants