I am using Joi validator for my HTTP requests. There I have a parameter called type
. I need to make sure that the possible values for the parameter are either "ios" or "android".
How can I do that?
body : {
device_key : joi.string().required(),
type : joi.string().required()
}
Maybe it will be useful for anyone who wants to check values based on existing enum/array of values.
Then just use this:
You can use
valid
.This gives an error
ValidationError: child "type" fails because ["type" must be one of [ios, android]]