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

Allow treating arrays as objects #659

Closed
pluma opened this issue May 27, 2015 · 5 comments · Fixed by #688
Closed

Allow treating arrays as objects #659

pluma opened this issue May 27, 2015 · 5 comments · Fixed by #688
Assignees
Labels
feature New functionality or improvement
Milestone

Comments

@pluma
Copy link
Contributor

pluma commented May 27, 2015

I know there are no plans to support having joi.array() apply different schemas to items at different indexes, but it would be very useful to be able to circumvent that by simply treating arrays as objects (like JS generally does already).

Example:

joi.object().type(Array).validate([])

Expected outcome: validation passes

Actual outcome: validation fails with "must be an object".

pluma added a commit to arangodb/arangodb that referenced this issue May 27, 2015
@Marsup Marsup added the request label May 27, 2015
@Marsup Marsup self-assigned this May 27, 2015
@Marsup
Copy link
Collaborator

Marsup commented May 27, 2015

I'd be open to a PR implementing Joi.array().items(...).ordered() that would set a new flag controlling that matches are made in the order provided in items. The flag has to be togglable as all the new ones I introduced.

@pluma
Copy link
Contributor Author

pluma commented May 28, 2015

That would work for me.

ck-lee added a commit to ck-lee/joi that referenced this issue Aug 8, 2015
closes hapijs#659

Update README.md

Update README.md

Update README.md

Update README.md

removed LF on lib/array.js
added reassignment of value if valid
added abortEarly case

fix lint for else keyword

always continue if valid or not for #ordered

added strip() for array ordered()

removed text used for test -grep

Fixed error when strip is not the last one in items.

Update README.md

remove trailing spaces

putting w into loop parameters
@Marsup
Copy link
Collaborator

Marsup commented Aug 24, 2015

@pluma mind having a look at the linked PR since you're the one asking ?

@Marsup Marsup added this to the 6.9.0 milestone Oct 5, 2015
@pluma
Copy link
Contributor Author

pluma commented Oct 7, 2015

👍 Thanks.

@hueniverse hueniverse added feature New functionality or improvement and removed request labels Sep 19, 2019
@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 a pull request may close this issue.

3 participants