The Question
I have an object that has been parsed from a JSON string. I want to confirm that its fields contain only primitive types (e.g. number, boolean, string). Specifically, I would like to confirm that all of the field values are not an object.
Does Joi have the concept of not? Can I do this without listing every possible non-object type?
The Attempt
I attempted to use any.disallow which is almost what I need (and, I realized after posting my question, is listed as having the alias not).
import Joi from 'joi'
const schema = Joi.object().keys({
myKey: Joi.any().not(Joi.object()),
})
However this seems to take values. This means it doesn't compare against schemas, and will consider any value that isn't the literal value returned by Joi.object() as valid.