Skip to content

Formal Validation with @Validation

Jan Bernitt edited this page May 20, 2026 · 14 revisions

This page is mainly meant as a overview or presentation around the introduction of formal input validation using @Validation as introduced by #23754.

Formal Input Validation

  • context-less (static context)
  • no state
  • no data related validation (just the input itself)
  • no semantic validation

Typical examples

  • property is required, e.g. name
  • number must be be positive, e.g. page
  • text must match a pattern, e.g. a UID
  • set of properties must be defined together, e.g. cc+co => coc

What is @Validation?

@Validation is a declarative Java-API for (a subset of) JSON-schema

🥳 we can extract JSON-schema conform JSON and include it in our OpenAPI documentation to inform clients about expectations that is both human and machine readable

It follows: If input is formally wrong, the caller made an avoidable mistake => BadRequestException

Clone this wiki locally