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

joi.allow array #3010

Closed
kroney opened this issue Jan 8, 2024 · 2 comments
Closed

joi.allow array #3010

kroney opened this issue Jan 8, 2024 · 2 comments
Labels
support Questions, discussions, and general support

Comments

@kroney
Copy link

kroney commented Jan 8, 2024

Runtime

node.js

Runtime version

20

Module version

17.11.0

Used with

No response

Any other relevant information

No response

How can we help?

Is there a way to use .allow() specifically to allow an array, e.g.:

Joi.string().allow(['a'])
// should allow any string and ['a']
// throws Uncaught Error: Method no longer accepts array arguments: allow

I can work around this by using alternatives or conditions, but I don't understand why allow does not accept arrays.

@kroney kroney added the support Questions, discussions, and general support label Jan 8, 2024
@cimbraien
Copy link

cimbraien commented Jan 12, 2024

If you need to allow different schemas, you can use alternative().
Docs

@Marsup
Copy link
Collaborator

Marsup commented Jan 12, 2024

allow is there to compare pure values, the moment you need to compare complex objects, you probably need schemas.

@kroney kroney closed this as completed Jan 24, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Questions, discussions, and general support
Projects
None yet
Development

No branches or pull requests

3 participants