konform-kt / konform

Portable validations for Kotlin
https://www.konform.io
MIT License
651 stars 39 forks source link

Exposing Validation Metadata #27

Closed brizzbuzz closed 3 years ago

brizzbuzz commented 3 years ago

Hey, I am working on an OpenAPI spec generator for Ktor https://github.com/bkbnio/kompendium and would love to build in Konform validation, but I am running into a problem. A method for generating validation metadata is eluding me.

Because all implementations of Validation are internal, and afaik the actual constraints don't get exposed to the end user, it feels like I am in a bit of a bind as far as pulling that info goes.

So I have a couple questions

  1. Am I just missing something? Is there an easy way to pull constraint metadata for a declared validation
  2. If not, are there any major concerns with exposing the list of constraints applied to a validation?
brizzbuzz commented 3 years ago

for visibility https://github.com/bkbnio/kompendium/issues/61

nlochschmidt commented 3 years ago

Nice project 👍🏻

Depending on what you would like to achieve exactly, just exposing the Constraints wouldn't help because the validation logic is not declarative but instead defined by lambdas.

In addition, while the built-in constraints are modelled after JSONSchema, the constraints used in practice can often not be described in terms of JSONSchema.

Maybe an alternative to look into for your project could be an integration with an actual JSONSchema validator.

brizzbuzz commented 3 years ago

Nice project

Tyty it's been a fun build :)

exposing the Constraints wouldn't help because the validation logic is not declarative but instead defined by lambdas.

ahhhh I see, that makes sense... I'll need to think more on this then.

gonna close this 👍