Feature idea: Using Joi for prop definition and validation, or adding Joi-like featuresSee original GitHub issue
Have you guys used Joi? I use Joi on the server-side with Hapi and really love it.
I just got started with Ampersand and also really, really love
ampersand-state. What a great tool. I was just in the middle of defining some properties on a view (!!!) and wanted to define valid values for one properties a function of the value of another property. Joi lets you do this with alternatives and references.
If Joi was adopted for properties, it could then also be used for validation. It would be a great win, I think. Defining a properties schema already gets you quite close to using that schema for validation.
This wouldn’t be trivial, of course. But I wanted to get this out there to see what you think. Joi is apparently browser-compatible via browserify, though they don’t run browser tests and they support things like Buffers. So, Joi may be too heavy for this purpose, and if so, perhaps just the above-mentioned reference/alternatives features could be added. And validation via properties’ schemas, I think, would be great too.
- Created 9 years ago
- Comments:13 (5 by maintainers)
Top GitHub Comments
This would be doable as a
dataTypemixin with a minor non-breaking change to
I ran a quick spike and this worked perfectly. I was able to create and use a
JoidataType mixin. The benefit of this change is that it allow much more powerful dataType mixing even outside of
Joi. Further, the above changes does not break anything and the tests continue to pass.
If this looks good, I’ll make it a PR.
This would be a wonderful thing as a mixin, great idea.