4 ms·
For validating entire objects: https://github.com/hapijs/joi https://github.com/hapijs/joi
by danlugo92 8y ago
For validating entire objects: https://github.com/hapijs/joi https://github.com/hapijs/joi
- aastronaut 8y ago...and its lightweight counterpart for the browser: https://github.com/jquense/yup https://github.com/jquense/yup
- Klathmon 8y agoI've also used AJV before. https://github.com/epoberezkin/ajv https://github.com/epoberezkin/ajv
- root_axis 8y agoMy company migrated everything away from joi in favor of AJV. Joi isn't serialisable and the maintainers are hostile to the idea of adding that capability. There are some 3rd party extensions to add serialization support, but they are not feature-complete. I also find the declarative nature of JSON Schema preferable to joi's semi-imperative API which is occasionally quite difficult to debug.
- steve_adams_86 8y agoWhy I like AJV or similar options is because you get to declare what you expect with a simple schema and it rarely needs to get complicated. It's more overhead than simple functional approaches combined with conditional statements, but I think it's more approachable. Otherwise I find it doesn't leave too much of a margin for error and it's reasonably fast. It's a personal preference, but I prefer it far more than a fluent interface. I actually avoid those now despite really loving them in the past.
- zumu 8y agoDoes anyone know if something like this exists for Ruby and or Java? Best I've found is a few libraries supporting JSON Schema.
- dbattaglia 8y agoFor Ruby the dry gems are pretty nice and help for validation (https://dry-rb.org https://dry-rb.org). There is a dry-validation module, although I found the dry-types and dry-struct gems even nicer for expressing validation directly on my model fields and hash schemes.
- throwaway2016a 8y ago+1 for joi. We use it extensively. It really reduces development time for us and it has some nice features like referencing other values in an object and evaluating the whole object at once (instead of fast fail) which is useful for APIs so you can return all the errors at once.