Skip to content

After transfer from server, throw error: TypeError: schema._validateWithOptions is not a function #15

@futurist

Description

@futurist

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions