When transfer joi definition from server, then JSON.parse as below:
// after a fetch from REST API
jsonFromServer.email === {"isJoi":true,"_type":"string","_settings":null,"_valids":{"_set":[]},"_invalids":{"_set":[""]},"_tests":[],"_refs":[],"_flags":{"presence":"required"},"_description":null,"_unit":null,"_notes":[],"_tags":[],"_examples":[],"_meta":[],"_inner":{}}
var emailType = joi.compile(jsonFromServer.email)
joi.attempt('abc', emailType)
// above line will throw error
The throwed error is:
TypeError: schema._validateWithOptions is not a function
Seems the joi type schema cannot be transferred from remote, then convert using this lib?
Or there's something more usage I'm missing?
When transfer
joidefinition from server, thenJSON.parseas below:The throwed error is:
Seems the joi type schema cannot be transferred from remote, then convert using this lib?
Or there's something more usage I'm missing?