Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
futurist opened this issue Feb 17, 2017 · 3 comments

Comments

@futurist
Copy link

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?

@futurist futurist changed the title TypeError: schema._validateWithOptions is not a function After transfer from server, throw error: TypeError: schema._validateWithOptions is not a function Feb 17, 2017
@jeffbski
Copy link
Owner

@futurist Thanks for raising the issue. I'll take a look and see if I can figure out what you are running into here.

@Marsup
Copy link

Marsup commented Feb 18, 2017

Joi objects are not serializable, you'd be missing the prototype. You have to have joi itself as well as the schemas on the client side. Maybe someday...

@jeffbski
Copy link
Owner

Thanks for explaining that @Marsup!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants