Search code examples
joihapi

How to check if string is valid by checking if its value is in array


joi.string().valid(['foo', 'bar']) has been deprecated.

Error: Method no longer accepts array arguments: allow

What is the new way of achieving this?


Solution

  • Using spread syntax works perfectly!

    joi.string().valid(...['foo', 'bar'])