Schema-refined — powerful "refined" steroids for schema library



We just released schema-refined - a couple of helpers for schema to increase its readability, precision, and composability

Rationale behind it could be found in @kachayev presentation


This looks extremely useful, thanks! Does this play well with generative testing, like the experimental schema generators?

Do you use schema with this library to model the domain of the code, or primarily for validation on the boundaries, e.g. database/external services/etc.? I am asking because I have tried using schema to model the domain previously, and ended up mainly using schemas at the boundaries; so I am curious about your approach and how it has worked out for you. I was by specifying things like “this is a phone number, it has this structure” but it eventually felt very heavy, adding schemas to lots of little helper functions.

I will give this lib a spin at some point, it definitely looks like an improvement on schema, and the readability is miles ahead of spec.



Thanks for the feedback! We’re using it to model & validate inputs and outputs (boundaries). We are not trying to cover all internal transformations as it usually leads to a significant mental overhead. You can find more on our usage/use cases in this slides:

Regarding generative testing. We didn’t look into that yet. We use property-based testing internally by didn’t have a chance to integrate schema-refined into that process. The most naive way of doing this would obviously lead to a pretty inefficient result and we want to take some time to wrap our heads around the problem and provide some “smart” way to built generators around predicates. That’s a really interesting topic!


I watched the slides and they provide a solid case for your changes. I especially like the way refined schemas are printed. Thinking some more about the use case for this, I am unsure how schema-refined compares to clojure.spec. Apart from the syntax they seem to be able to express the same constraints. Did you make schema-refined because switching to spec was infeasible for your existing code base, or are you using it for green field projects as well? If yes, what, in your opinion, are the pros and cons of schema-refined compared to spec?