- Overview
- Quick Start
- Introduction
- Guides
- Client Libraries
- API Reference
- Examples
- DDD Resources
- Validation user guide
- Validation developer guide
Summary
This section walked through the complete workflow for adding a custom validation option to the Spine Validation library, from declaring the option in Protobuf to making it available to the Spine Compiler.
What you covered
Declare the option in Protobuf — define a Protobuf
extendblock targeting a standard descriptor option type, with a unique field number and an error message template that supports named placeholders.Register the option — wire an
OptionsProviderto register the Protobuf extension at runtime, and aValidationOptionto bind the option name to itsReaction,View, andGenerator. Both are discovered via JavaServiceLoader.Declare the event and view state — define a domain event emitted when the option is encountered, and a projection state message the
Generatorqueries to accumulate option data.Implement the
Reaction— subscribe toFieldOptionDiscoveredevents, filter by option name, validate the field type and option value, and emit the domain event — or signal no reaction when the option is disabled.Implement the
View— build a projection that accumulates event data, making the full set of option applications queryable by theGenerator.Implement the
Generator— query theViewand produce Java validation code inlined into the generatedvalidate()method, handling both single and repeated field cardinalities.Pass the option to the Compiler — place the
ValidationOptionimplementation on the Compiler’s user classpath via a directspineCompilerdependency or a distributable Gradle plugin.
What’s next
- Explore library internals: Developer’s guide
- See the modules that back this pipeline: Key modules
The complete source for all running examples is in the
validation module of the Spine Time repository.