JuliaCon 2023

Declaratively imposing constraints using ValueConstraints.jl
2023-07-28 , 32-144

ValueConstraints.jl provides a framework for declaratively expressing constraints on values, e.g. "minimum", "maximum", "needs to be within this set", etc. along with a small standard library of common constraints. It is fast, i.e. on par with using regular function calls, provides friendly error messages and warnings, and, perhaps most importantly, can serve as a foundation for the creation of schemas.


The need to be able to express constraints on data is common in various aspects of software engineering. A particular example that might come to mind is API design, especially inter-process API design, where it is useful to be able to make expose these constraints to consumers of the API. For instance, the OpenAPI specification is a specification for REST APIs and is in turn an extension of the JSON Schema specification. The OpenAPI specification leverages the JSON Schema Validation specification to document constraints on data submitted to API endpoints.

Although the Julia ecosystem has packages that handle the parsing of these types of schemas, such as JSONSchema.jl or OpenAPI.jl, there is no such package making it easy to generate these types of schemas from Julia code. ValueConstraints.jl aims to fill that gap. It takes a declarative and introspectable approach to expressing constraints on values, so that other packages like StructTypes.jl can be used to serialize the constraints into and from formats such as JSON Schema.

Joris is driven by a need for automation and to make things easier for himself, typically while first making them harder. He has been creating CI processes for Julia (and other languages) for as long as he has been programming in Julia (which has been a while), primarily for GitLab, but also for other platforms such as GitHub and Buildkite. He has also been building web-based Julia applications for the same amount of time, trying to find more efficient ways of building those at every step.

Joris is the technical team lead for the JuliaSim product and applications team.

This speaker also appears in: