Closed timrobertsdev closed 2 years ago
Thanks for the MR. I started Konform with the idea of building a kind of generator to transform a limit subset of a JSON Schema code to Konform later. Therefore I started with implementing validations that are like what can be found there. The thing is, between
, betweenExclusive
and inRange
are not part of JSON Schema, so I need to think about where to put them.
How would something like this work for you?
With this approach, you can group all validators together in a base abstract class, then expose only the ones applicable for your scenario in an object, and the only change needed for calling code is a different import. It's kind of annoying to write out the function definitions twice, but it works.
I'm not sure about the overhead of an extra function call, but I would think the compiler/JIT would optimize most of that away.
That could work.
However, since many kinds of validations can be added from the outside without actually changing the library (see #7) I would rather not include them right now. I think it will be interesting to provide multiple styles like json-schema, swagger-schema (see #6) and maybe hibernate-validator style validations before introducing a new custom konform-style set of validations.
But I'll keep this issue open as a reminder.
Inspired by this reddit comment.
Instead of writing
the user could instead use