Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
a8cef7f
Bump version -> `2.0.0-SNAPSHOT.416`
alexander-yevsyukov May 5, 2026
5c5d60c
Bump Validation -> `2.0.0-SNAPSHOT.415`
alexander-yevsyukov May 5, 2026
46d1004
Bump Validation in docs
alexander-yevsyukov May 5, 2026
7ab7dc3
Update `_examples` ref.
alexander-yevsyukov May 5, 2026
2dba107
Bump Gradle -> `9.5.0`
alexander-yevsyukov May 5, 2026
391adf5
Update dependency reports
alexander-yevsyukov May 5, 2026
fd36d85
Update (c) header
alexander-yevsyukov May 5, 2026
ace531d
Remove duplicated references to `spine/options.proto`
alexander-yevsyukov May 5, 2026
019208b
Strip the outdated content from `README.md`
alexander-yevsyukov May 5, 2026
c09686d
Add "Why" and "How it works" sections to the overview documentation
alexander-yevsyukov May 5, 2026
bdc978a
Improve root section name
alexander-yevsyukov May 5, 2026
131ef01
Improve readability of the "Key modules" section
alexander-yevsyukov May 5, 2026
7bc1a23
Update Developer's guide section number
alexander-yevsyukov May 5, 2026
f7768f7
Add plan for writing Developer's guie
alexander-yevsyukov May 5, 2026
5ca5f7c
Draft the Architecture section
alexander-yevsyukov May 5, 2026
301986f
Update `embed-code-go` binaries
alexander-yevsyukov May 5, 2026
462705b
Add more code roots for `embed-code`
alexander-yevsyukov May 5, 2026
8a24808
Use `embed-code` for samples
alexander-yevsyukov May 5, 2026
974b8a6
Add overview section and page placeholders
alexander-yevsyukov May 5, 2026
68d5290
Improve margins on the architecture diagram
alexander-yevsyukov May 5, 2026
43cba27
Update sequence of sections in the plan
alexander-yevsyukov May 5, 2026
6d7d1d9
Add missing comma
alexander-yevsyukov May 5, 2026
45cf382
Add Validation model section
alexander-yevsyukov May 5, 2026
11e3854
Remove "(deep dive)" suffix
alexander-yevsyukov May 5, 2026
c35fde5
Use sentence capitalization
alexander-yevsyukov May 5, 2026
fafc056
Use typography quotes around a link in the text
alexander-yevsyukov May 5, 2026
3cffd56
Avoid module names in titles
alexander-yevsyukov May 5, 2026
3738b41
Fix the delivery path in Mermaid diagram
alexander-yevsyukov May 5, 2026
92425c4
Avoid referencing "AST node" in docs
alexander-yevsyukov May 6, 2026
be26044
Improve table format in Markdown
alexander-yevsyukov May 6, 2026
fb9c9f7
Add Java code generation section
alexander-yevsyukov May 6, 2026
c3a5853
Improve wording of Java codegen docs
alexander-yevsyukov May 6, 2026
65a5cac
Populate runtime library documentation
alexander-yevsyukov May 6, 2026
e6164ab
Improve wording of the Runtime library section
alexander-yevsyukov May 6, 2026
a792bf9
Update `site-commons`
alexander-yevsyukov May 6, 2026
5bba868
Draft Extension points section
alexander-yevsyukov May 6, 2026
20a2e94
Draft Extension points section
alexander-yevsyukov May 6, 2026
ca1f947
Fix references to `MessageValidator`
alexander-yevsyukov May 6, 2026
4221a73
Update `site-commons`
alexander-yevsyukov May 6, 2026
848ad77
Add first version of "Adding a built-in option" section
alexander-yevsyukov May 6, 2026
f75f0ed
Link to IntelliJ PSI page
alexander-yevsyukov May 6, 2026
7b50f13
Update `site-commons` via Codex
alexander-yevsyukov May 6, 2026
21c7108
Improve wording of `extension-points.md`
alexander-yevsyukov May 6, 2026
c04ff9a
Fix references to Base Libraries
alexander-yevsyukov May 6, 2026
63bf601
Add non-breaking spaces to improve text flow
alexander-yevsyukov May 6, 2026
05a71ff
Add non-breaking spaces to improve text flow
alexander-yevsyukov May 6, 2026
1fe5880
Improve `/writer` to use typographic quotes
alexander-yevsyukov May 6, 2026
fe5f987
Add non-breaking space for better text flow
alexander-yevsyukov May 6, 2026
4f0af9e
Improve the guidelines of using typographic quotes in links
alexander-yevsyukov May 6, 2026
f3ee630
Fix using typographic quotes in links
alexander-yevsyukov May 6, 2026
db56b1e
Fix using typographic quotes in links
alexander-yevsyukov May 6, 2026
1810c30
Move User and Developer guides into subdirectories
alexander-yevsyukov May 6, 2026
d65f217
Improve selection of the section in navigation
alexander-yevsyukov May 6, 2026
67e2244
Remove outdated file
alexander-yevsyukov May 6, 2026
c672924
Use non-breaking space in header for better readability
alexander-yevsyukov May 6, 2026
a6dd715
Describe testing strategy
alexander-yevsyukov May 6, 2026
5253f46
Fix capitalization for ProtoTap
alexander-yevsyukov May 6, 2026
a47b0f5
Fix capitalization for ProtoTap
alexander-yevsyukov May 6, 2026
878885c
Improve wording of the Testing strategy section
alexander-yevsyukov May 6, 2026
11a1c12
Fix the text flow with non-breaking space
alexander-yevsyukov May 6, 2026
1e6e957
Add link to CoreJvm Compiler repository in the plan
alexander-yevsyukov May 6, 2026
2d51143
Fix capitalization of ProtoTap
alexander-yevsyukov May 6, 2026
28c3fb1
Add the link to ProtoTap repo
alexander-yevsyukov May 6, 2026
23a2e10
Fix capitalization of the Compiler
alexander-yevsyukov May 6, 2026
1c7f8c8
Add the link to Google Truth site
alexander-yevsyukov May 6, 2026
8997d85
Update site-commons
alexander-yevsyukov May 7, 2026
9aa06ae
Update `site-commons` in `docs/_preview`
alexander-yevsyukov May 7, 2026
e0c83cb
Remove custom navigation tunning
alexander-yevsyukov May 7, 2026
6a5c74e
Fix file reference in `CLAUDE.md`
alexander-yevsyukov May 7, 2026
f6eb9a1
Avoid module names in titles
alexander-yevsyukov May 7, 2026
6d48e83
Ignore `/.claude/worktrees/`
alexander-yevsyukov May 7, 2026
9e1d2c4
Draft `build-and-release.md`
alexander-yevsyukov May 7, 2026
a126a94
Improve the property name
alexander-yevsyukov May 7, 2026
82d9d41
Use `embed-code` for samples
alexander-yevsyukov May 7, 2026
c3b1274
Remove outdated exclusion
alexander-yevsyukov May 7, 2026
78afd1b
Add `root` code path
alexander-yevsyukov May 7, 2026
bcf3703
Fix comment reference to Spine Compiler
alexander-yevsyukov May 7, 2026
7971c60
Draft `build-and-release.md`
alexander-yevsyukov May 7, 2026
b87bf39
Fix property name
alexander-yevsyukov May 7, 2026
8e7f0f8
Use `embed-code`
alexander-yevsyukov May 7, 2026
27180bb
Improve wording of `build-and-release.md`
alexander-yevsyukov May 7, 2026
e93d7f8
Fix reference to the Spine Compiler
alexander-yevsyukov May 7, 2026
5e624db
Narrow down file types for embedding
alexander-yevsyukov May 7, 2026
ae24f4a
Sort out code embeddings
alexander-yevsyukov May 7, 2026
251b60b
Update build time
alexander-yevsyukov May 7, 2026
f651ecf
Update the link in `README.md`
alexander-yevsyukov May 7, 2026
64481d4
Remove the plan document
alexander-yevsyukov May 7, 2026
e3fd344
Avoid end-of-code comment
alexander-yevsyukov May 7, 2026
eeb5cea
Return end-of-code suffix
alexander-yevsyukov May 7, 2026
71dcbae
Fix broken links
alexander-yevsyukov May 7, 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
9 changes: 9 additions & 0 deletions .agents/skills/writer/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ description: >

- Follow `.agents/documentation-guidelines.md` and `.agents/documentation-tasks.md`.
- Use fenced code blocks for commands and examples; format file/dir names as code.
- When referencing a documentation page or section in body prose, use typographic
double quotation marks only if the visible reference text is the actual page or
section title, such as the “Getting started” page or the “Troubleshooting”
section. The title normally starts with a capital letter. Do not add these
quotes around generic or descriptive links such as “this page”, “the next
section”, “declaring constraints”, or `4.3`, even if they point to a page or
section. Do not add these quotes in “What’s next” sections or navigation
elements. Keep file paths, identifiers, frontmatter values, navigation labels,
and Markdown link labels in their expected syntax.
- In Markdown files, prefer footnote-style reference links for external `https://`
targets instead of inline links. Write readable body text like
`[label][short-id]`, then place the URL definition near the end of the file,
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,4 @@ pubspec.lock
# Python cache
__pycache__/
*.pyc
/.claude/worktrees/
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Agent Guidelines
Please read and follow all guidelines in the project's agent documentation:

- Start with the table of contents: `./agents/_TOC.md`.
- Start with the table of contents: `.agents/_TOC.md`.
- Follow all linked documents from the TOC.
- Apply all coding standards, formatting rules, and project conventions found in these documents.

Expand Down
88 changes: 10 additions & 78 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ Spine Validation solves this by modifying the code generated by the Protobuf com
At build time, Spine Validation injects assertions directly into the generated Java classes,
enabling automatic enforcement of constraints without explicit API calls in application code.

## Table of Contents

- [Prerequisites](#prerequisites)
- [Validation in Action](#validation-in-action)
- [Architecture](#architecture)
- [Extending the Library](#extending-the-library)

## Prerequisites

This library is built with Java 17.
Expand Down Expand Up @@ -78,12 +71,12 @@ optionalError.ifPresent(err -> {
});
```

### Validation Options
## Validation Options

Validation options are defined by the following files:

1. [options.proto](https://github.com/SpineEventEngine/base-libraries/blob/master/base/src/main/proto/spine/options.proto).
2. [time_options.proto](https://github.com/SpineEventEngine/time/blob/master/time/src/main/proto/spine/time_options.proto).
1. [`options.proto`][options-proto]
2. [`time_options.proto`][time-options-proto]

Users must import these .proto files to use the options they define.

Expand All @@ -92,81 +85,20 @@ import "spine/options.proto"; // Brings all options, except for time-related one
import "spine/time_options.proto"; // Brings time-related options.
```

# Adding custom validation
## Adding custom validation

Users can extend the library by providing custom Protobuf options and code generation logic.

Follow these steps to create a custom option:

1. Declare a Protobuf [extension](https://protobuf.dev/programming-guides/proto3/#customoptions)
in your `.proto` file.
2. Register it via `io.spine.option.OptionsProvider`.
3. Implement the following entities:
- Policy (`MyOptionPolicy`) – discovers and validates the option.
- View (`MyOptionView`) – accumulates valid option applications.
- Generator (`MyOptionGenerator`) – generates Java code for the option.
4. Register them via `io.spine.tools.validation.java.ValidationOption`.

Below is a workflow diagram for a typical option:

![Typical custom option](.github/readme/typical_custom_option.jpg)

Take a look at the `:java-tests:extensions` module that contains a full example of
implementation of the custom `(currency)` option.

Note that a custom option can provide several policies and views, but only one generator.
This allows building more complex models, using more entities and events.

Let's take a closer look at each entity.

### Policy

Usually, this is an entry point to the option handling.

The policy subscribes to one of `*OptionDiscovered` events:

- `FileOptionDiscovered`.
- `MessageOptionDiscovered`.
- `FieldOptionDiscovered`.
- `OneofOptionDiscovered`.

It filters incoming events, taking only those who contain the option of the interest. The policy
may validate the option application, query `TypeSystem`, extract and transform data arrived with
the option, if any. Once ready, it emits an event signaling that the discovered option is valid
and ready for the code generation.

The policy may report a compilation warning or an error, failing the whole compilation if it
finds an illegal application of the option.

For example:

1. An unsupported field type.
2. Illegal option content (invalid regex, parameter, signature).

The policy may just ignore the discovered option and emit `NoReaction`. A typical example
of this is a boolean option, such as `(required)`, which does nothing when it is set to `false`.

The desired behavior depends on the option itself.

### View

Views accumulate events from policies, serving as data providers for the validation model
used by code generators. Views are typically simple and only accumulate data; for more complex
logic, use policies.

Usually, one view represents a single application of an option.

### Generator

The generator is an entity that provides an actual implementation of the option behavior.
The generator produces Java code for every application of that option within the message type.

It has access to the `Querying` interface and can query views to find those belonging
to the processed message type.
See the [Custom validation][custom-validation] section
of the User Guide for details.
Comment thread
alexander-yevsyukov marked this conversation as resolved.

[codecov]: https://codecov.io/gh/SpineEventEngine/validation
[codecov-badge]: https://codecov.io/gh/SpineEventEngine/validation/branch/master/graph/badge.svg
[license-badge]: https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat
[license]: http://www.apache.org/licenses/LICENSE-2.0
[gh-actions]: https://github.com/SpineEventEngine/validation/actions
[ubuntu-build-badge]: https://github.com/SpineEventEngine/validation/actions/workflows/build-on-ubuntu.yml/badge.svg

[options-proto]: https://github.com/SpineEventEngine/base-libraries/blob/master/base/src/main/proto/spine/options.proto
[time-options-proto]: https://github.com/SpineEventEngine/time/blob/master/time/src/main/proto/spine/time_options.proto
[custom-validation]: docs/content/docs/validation/user/05-custom-validation/_index.md
12 changes: 2 additions & 10 deletions buildSrc/src/main/kotlin/fat-jar.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2023, TeamDev. All rights reserved.
* Copyright 2026, TeamDev. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Redistribution and use in source and/or binary forms, with or without
* modification, must retain the above copyright notice and the following
Expand Down Expand Up @@ -55,14 +55,6 @@ tasks.publish {

tasks.shadowJar {
exclude(
/*
* Excluding this type to avoid it being located in the fat JAR.
*
* Locating this type in its own `io:spine:protodata` artifact is crucial
* for obtaining proper version values from the manifest file.
* This file is only present in the `io:spine:protodata` artifact.
*/
"io/spine/protodata/gradle/plugin/Plugin.class",
"META-INF/gradle-plugins/io.spine.tools.compiler.properties",

/*
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.414"
const val version = "2.0.0-SNAPSHOT.415"
Comment thread
alexander-yevsyukov marked this conversation as resolved.
Comment thread
alexander-yevsyukov marked this conversation as resolved.
Comment thread
alexander-yevsyukov marked this conversation as resolved.
Comment thread
alexander-yevsyukov marked this conversation as resolved.

/**
Comment on lines 37 to 41
* The last version of Validation compatible with ProtoData.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ package io.spine.tools.validation
* We have the same items in this enum as in `io.spine.validation.RuntimeErrorPlaceholder`
* in the runtime library, which is exactly as this one. Please keep them in sync.
* This duplication is done intentionally to prevent clash between the runtime library,
* which is added to the classpath of the Compiler and the runtime library, which is part
* which is added to the classpath of the Compiler, and the runtime library, which is part
* of the Compiler itself because it is a part of Spine. As we complete our migration
* of validation to codegen, the runtime library will either be significantly simplified,
* or even its content may be moved to `base`. Then, the duplicate enum should be removed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ public abstract class ValidationPlugin(
IfSetAgainReaction(),
RequireReaction()
)
)
) // Plugin
Loading
Loading