Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
eb2eca3
Bump version -> `2.0.0-SNAPSHOT.401`
alexander-yevsyukov Mar 2, 2026
6d631f1
Capitalize "Validation"
alexander-yevsyukov Mar 2, 2026
9ddcb0f
Fix the placement path
alexander-yevsyukov Mar 2, 2026
1aabc21
Add `TimestampValidator`
alexander-yevsyukov Mar 2, 2026
e4d0a3f
Optimise imports
alexander-yevsyukov Mar 2, 2026
14e04a9
Update the implementation path
alexander-yevsyukov Mar 2, 2026
e39cab0
Update the implementation path
alexander-yevsyukov Mar 2, 2026
63cb5ea
Update the task on 3rd party message validation
alexander-yevsyukov Mar 2, 2026
f363431
Update the task on 3rd party message validation
alexander-yevsyukov Mar 2, 2026
2353e9d
Update `_examples` ref.
alexander-yevsyukov Mar 2, 2026
46da80e
Add text for "Validating third-party messages"
alexander-yevsyukov Mar 2, 2026
ca0c4ac
Add placeholders when reporting `Timestamp` violations
alexander-yevsyukov Mar 2, 2026
75852bc
Add code fragment "core"
alexander-yevsyukov Mar 2, 2026
a6eb7c5
Rename the section "Validating third-party messages" to "Validating e…
alexander-yevsyukov Mar 2, 2026
441db1a
Extract `implement-an-external-validator.md` document
alexander-yevsyukov Mar 2, 2026
4247c7a
Adjust the intro text for `TimestampValidator` review
alexander-yevsyukov Mar 2, 2026
54c22a2
Fix test suite class name
alexander-yevsyukov Mar 2, 2026
edcb7f1
Add details on the `TimestampValidator` implementation
alexander-yevsyukov Mar 2, 2026
3ff579f
Update dependency reports
alexander-yevsyukov Mar 2, 2026
1dc9b1a
Pull violation functions at the file level
alexander-yevsyukov Mar 2, 2026
76c550a
Bump Validation -> `2.0.0-SNAPSHOT.400`
alexander-yevsyukov Mar 3, 2026
8c459a0
Update dependency reports
alexander-yevsyukov Mar 3, 2026
bd0cddb
Add resource entry for `TimestampValidator`
alexander-yevsyukov Mar 3, 2026
58b8f49
Improve property name
alexander-yevsyukov Mar 3, 2026
4b89c8d
Extract reading discovered validators
alexander-yevsyukov Mar 3, 2026
2bdb330
Extract separator for message validator lines
alexander-yevsyukov Mar 3, 2026
6be579e
Consolidate composition and parsing under `MessageValidatorFile`
alexander-yevsyukov Mar 3, 2026
d7c5a45
Optimise imports
alexander-yevsyukov Mar 3, 2026
f06d46b
Load validators from resources
alexander-yevsyukov Mar 3, 2026
76abea1
Update build time
alexander-yevsyukov Mar 3, 2026
c389323
Narrow down filtering of proto files
alexander-yevsyukov Mar 3, 2026
cf20056
Update build time
alexander-yevsyukov Mar 3, 2026
b10d703
Update `_examples` ref.
alexander-yevsyukov Mar 3, 2026
ff61c82
Optimise imports
alexander-yevsyukov Mar 4, 2026
78edd47
Allow validators for local messages
alexander-yevsyukov Mar 4, 2026
2488663
Remove outdated documentation statements
alexander-yevsyukov Mar 4, 2026
74b767b
Add task document for `ValidatorRegistry`
alexander-yevsyukov Mar 4, 2026
50852db
Add initial implementation of `ValidatorRegistry`
alexander-yevsyukov Mar 4, 2026
3de40fb
Pull the extension to the file level
alexander-yevsyukov Mar 4, 2026
46916ea
Obtain message class via type token
alexander-yevsyukov Mar 4, 2026
0e14c09
Use qualified class names as keys in `ValidatorRegistry`
alexander-yevsyukov Mar 4, 2026
348d1fe
Return `ConstraintViolation`s from `ValidatorRegistry.validate()`
alexander-yevsyukov Mar 4, 2026
731ada7
Fix capitlization and punctuation
alexander-yevsyukov Mar 4, 2026
381e548
Update build time
alexander-yevsyukov Mar 4, 2026
c8a8f1d
Update dependency reports
alexander-yevsyukov Mar 5, 2026
789bffd
Use `ValidatorRegistry` for top-level and nested validation
alexander-yevsyukov Mar 5, 2026
391541b
Update dependency reports
alexander-yevsyukov Mar 5, 2026
8e3a60c
Document the code branch
alexander-yevsyukov Mar 5, 2026
2e6ceb8
Archive done task
alexander-yevsyukov Mar 5, 2026
14b7af5
Document parameters
alexander-yevsyukov Mar 5, 2026
a7b79ec
Update build time
alexander-yevsyukov Mar 5, 2026
eecfadf
Fix doc grammar
alexander-yevsyukov Mar 5, 2026
0831084
Extract validation block into a var
alexander-yevsyukov Mar 6, 2026
66420d4
Fail on invalid `Any`s, avoid comparison with empty list or map
alexander-yevsyukov Mar 6, 2026
2c778f5
Improve test suite names
alexander-yevsyukov Mar 6, 2026
014edef
Bump JUnit -> `6.0.3`
alexander-yevsyukov Mar 6, 2026
7a165f4
Update dependency reports
alexander-yevsyukov Mar 6, 2026
cb40d40
Add support for the `validator` placeholder in reported violations
alexander-yevsyukov Mar 6, 2026
102463f
Handle `validator` placeholder in assertions
alexander-yevsyukov Mar 6, 2026
78ab847
Improve documentation of `VALIDATOR_PLACEHOLDER`
alexander-yevsyukov Mar 6, 2026
db1231e
Update the plan on describing validators
alexander-yevsyukov Mar 6, 2026
496236b
Rewrite "external messages" section
alexander-yevsyukov Mar 6, 2026
87c89b7
Archive the task
alexander-yevsyukov Mar 6, 2026
fa46047
Allow querying validators
alexander-yevsyukov Mar 6, 2026
220457a
Add task item on creating a page for `ValidatorRegistry`
alexander-yevsyukov Mar 6, 2026
e55b684
Add page on using `ValidatorRegistry`
alexander-yevsyukov Mar 6, 2026
f430795
Allow using Java classes in `ValidatiorRegistry`
alexander-yevsyukov Mar 6, 2026
f133c28
Update jvm-runtime/src/main/kotlin/io/spine/validation/ValidatorRegis…
alexander-yevsyukov Mar 6, 2026
41adca0
Update jvm-runtime/src/main/kotlin/io/spine/validation/Validator.kt
alexander-yevsyukov Mar 6, 2026
b00cdb6
Fix typo
alexander-yevsyukov Mar 6, 2026
28c118b
Update build time
alexander-yevsyukov Mar 6, 2026
0374848
Make `ValidatorRegistry` thread-safe
alexander-yevsyukov Mar 9, 2026
c171349
Archive the task
alexander-yevsyukov Mar 9, 2026
61cf322
Avoid using reflection in tests
alexander-yevsyukov Mar 9, 2026
4db6db7
Update build time
alexander-yevsyukov Mar 9, 2026
09c63c6
Add the note on configuring AutoService
alexander-yevsyukov Mar 9, 2026
2d8ade3
Avoid unused variable
alexander-yevsyukov Mar 9, 2026
d8fb452
Clarify when validators work
alexander-yevsyukov Mar 9, 2026
09a9393
Fix titles and capitalization
alexander-yevsyukov Mar 9, 2026
8e0fc4f
Narrow down use case description
alexander-yevsyukov Mar 9, 2026
1a0d525
Add missing period and backticks
alexander-yevsyukov Mar 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .agents/tasks/archive/rewrite-external-messages-section.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Task: Rewrite the "External messages" section of the documentation
- New name for the section: "Using Validators"
- Purpose: explain how to use validators in code, including how to create and apply them to proto messages.
- Target outcome: a reader can create a validator for a proto message, apply it to an external
message and to a local message likewise.
- Cases for using validators
- External messages: the message the modification of source code is not possible (e.g. messages in libraries).
- Validation of local messages that require computation or custom logic that cannot be expressed in proto options.
- Describe that multiple validations can be applied to the same message type.

## Describe creating a validator
- Implement `io.spine.validation.MessageValidator<M>`.
- Describe automatic discovered of validators using the `ServiceLoader` mechanism.
- Mention using `AutoService` to generate the service provider configuration file.
- Mention that it is possible to add a validator to `ValidatorRegistry` explicitly during
application startup or configuration. This is an alternative to service discovery approach.
- Describe the requirement for a public no-args constructor.

## Keep the `implement-an-external-validator.md` page
- Rename the file to `implement-a-validator.md`.
- Remove using the `@Validator` annotation from the example, and instead show using `@AutoService`.
- Add the page to `sidenav.yml`.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ validating local messages.
## Placement

- Placement of the page: after “Built-in options”, before “Custom validation”.
- Hugo section (minimal change): add the page under `docs/content/docs/validation/02-concepts/`.
- Hugo section (minimal change): add the page under `docs/content/docs/validation/03-built-in-options/`.
If the site navigation later gains an “Advanced topics” section, the page can move there.

## Planned content
Expand All @@ -39,20 +39,17 @@ validating local messages.
- Return `List<DetectedViolation>`.
- Use `FieldViolation` (and other available violation types) to point at a field path and value.
- Mention that the runtime converts `DetectedViolation` into `ConstraintViolation`/`ValidationError`.
- Constraints and guardrails:
- Exactly one validator per external message type (duplicate is an error).
- Validators for local messages are prohibited (use options/codegen instead).
- Example walkthrough (short, copy-pastable):
- Implement `EarphonesValidator` (from `:tests:validator`) and show how it affects a local message
that contains an `Earphones` field.
- Implement `TimestampValidator` (from `:jvm-runtime`) and show how it affects a local message
that contains a `Timestamp` field.

## Source references to anchor the docs

- External validation API and requirements:
- `jvm-runtime/src/main/kotlin/io/spine/validation/MessageValidator.kt`
- `jvm-runtime/src/main/kotlin/io/spine/validation/Validator.kt`
- Example implementation:
- `tests/validator/src/main/kotlin/io/spine/tools/validation/test/EarphonesValidator.kt`
- `jvm-runtime/src/main/kotlin/io/spine/validation/TimestampValidator.kt`

## Output

Expand Down
22 changes: 22 additions & 0 deletions .agents/tasks/archive/using-validator-registry-section.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Task: create a page about `ValidatorRegistry` and how to use it

## Main idea
In simple cases the programmer using the Validation library does not need to interact
with `ValidatorRegistry` directly, as the library discovers and applies validators automatically.

However, in some cases it may be necessary to interact with the registry directly,
for example, to add a validator explicitly or to query the registry for registered validators.

## Features
- Discovery and loading validators using the `ServiceLoader` mechanism.
- Setting `validator` placeholder in the reported violation messages.
- Adding validators.
- Quering and removal of registered validators.

## Edge case
- Overwriting validation by automatically registered validators by removing them from the
registry and adding new validators.

## Placement
- Add the page after "Implement a validator" page.
- Update `sidenav.yml` accodringly.
25 changes: 25 additions & 0 deletions .agents/tasks/archive/validator-registry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Task: Implement a registry for custom validators of Protobuf messages

This task involves creating a registry system that allows for the dynamic registration and retrieval
of custom validators for Protobuf messages.
The registry should support adding new validators at runtime and efficiently look up validators
based on message types.

## Goals
- Design a flexible and efficient registry for custom validators implementing
the `MessageValidator` interface.

## Target class
- `io.spine.validation.ValidatorRegistry`

## Module
- `jvm-runtime`

## Features
- Ability to add custom validators for specific Protobuf message types.
- Support several validators per type.
- Ability to remove validators from the registry for a given type.
- Ability to clear the whole registry.
- Load validators from the classpath using Java's ServiceLoader mechanism.
- API for validating a message by looking up its type in the registry and
applying all associated validators.
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ spinePublishing {
"java",
"java-bundle",
"jvm-runtime",
"ksp",
)
modulesWithCustomPublishing = setOf(
"java-bundle",
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/fat-jar.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ tasks.shadowJar {
"resources/com/pty4j/**",

// Protobuf files.
"google/**",
"spine/**",
"google/**/*.proto",
"spine/**/*.proto",
"src/**",

// Java source code files of the package `org.osgi`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object Validation {
/**
* The version of the Validation library artifacts.
*/
const val version = "2.0.0-SNAPSHOT.395"
const val version = "2.0.0-SNAPSHOT.400"

/**
* The last version of Validation compatible with ProtoData.
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/io/spine/dependency/test/JUnit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import io.spine.dependency.DependencyWithBom
@Suppress("unused", "ConstPropertyName")
object JUnit : DependencyWithBom() {

override val version = "6.0.0"
override val version = "6.0.3"
override val group: String = "org.junit"

/**
Expand Down
Loading
Loading