danielsz/system

Validation with schema

danielsz opened this issue · 2 comments

I suggest to use Prismatic's schema for validation.

It's very well capable and trusted, and I feel it's a more elegant solution than the custom rolled assertions we're doing now.

I've started using Prismatic schema with the Mongo component.

It would be desirable to go back to components that have assertions and turn them into Schema validations. (Jetty, Http-kit, Immutant, etc.)

Contributions welcome.

This is a good task for Clojure learners, as it's a simple task (and I'll help).

Noticed this article while I was looking around though, thought it might be interesting if you hadn't already seen it https://blog.juxt.pro/posts/component-meet-schema.html

@brabster

This is very pertinent information, and if anyone has a specific idea on how to leverage this, I'm all ears.

The article is from a user perspective, who can do validations when the system is being assembled. As a library, we are doing validation on the constructor of the component. We cannot necessarily do all the validations described, am I wrong?

At any rate, this is the kind of things that would fit in a section in the README. A paragraph on the kind of validation mentioning that we do, the kind of validations that is possible to do, and a link to Juxt's article.

Thanks to @brabster's work, we now have validations via schema.

It is possible to go further with that library, namely Plumatic's take on type hints, but that has its own set of drawbacks. Please refer to #66 to see the proposed changes.

The discussion is open.