Re:V8n – Fluent validation library for JavaScript
by danlugo92 on Sunday July 15, 2018 @01:06PM
(#17536038)
For validating entire objects: https://github.com/hapijs/joi
[ Parent
| on HN ]
Re:V8n – Fluent validation library for JavaScript
by Klathmon on Sunday July 15, 2018 @02:43PM
(#17536412)
I've also used AJV before.
Re:V8n – Fluent validation library for JavaScript
by root_axis on Sunday July 15, 2018 @03:00PM
(#17536472)
My 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.
Re:V8n – Fluent validation library for JavaScript
by steve_adams_86 on Sunday July 15, 2018 @09:40PM
(#17538175)
Why 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.
Re:V8n – Fluent validation library for JavaScript
by aastronaut on Sunday July 15, 2018 @01:09PM
(#17536055)
...and its lightweight counterpart for the browser: https://github.com/jquense/yup
Re:V8n – Fluent validation library for JavaScript
by throwaway2016a on Sunday July 15, 2018 @09:39PM
(#17538171)
+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.
Re:V8n – Fluent validation library for JavaScript
by zumu on Sunday July 15, 2018 @03:30PM
(#17536632)
Does anyone know if something like this exists for Ruby and or Java?
Best I've found is a few libraries supporting JSON Schema.
Re:V8n – Fluent validation library for JavaScript
by dbattaglia on Sunday July 15, 2018 @07:33PM
(#17537719)
For Ruby the dry gems are pretty nice and help for validation (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.