Is it possible to convert a joi schema to json, so that it can be sent from server to clients, instead of copying code or using eval() ?
What do you want to do with it on clients ?
@Marsup There are alternative ways to have the similar effect, but for me it would be easier to maintain and debug if joi schema can be passed to clients. Let's say I want to validate data on client side before sending to server and I know that the schema on both sides are the same. The simplest way is to copy the code to both sides, but I got more than a handful of schemes and they are changing...
@raisch looks good~ thanks
Then you need it both ways, not only to JSON. #314 can give you ways to achieve that but there's currently nothing out of the box, you're welcome to work on it.
Is there any update on this thread? I need to implement both ways joi schema to json and back. Is there any way?
I'm still failing to see actual needs for that. The usual case is you create schemas and you share them with the frontend with webpack, I see no reason to work on that, even more so as some cases are impossible to serialize.
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.
Most helpful comment
Is there any update on this thread? I need to implement both ways joi schema to json and back. Is there any way?