generated from SpineEventEngine/template
-
Notifications
You must be signed in to change notification settings - Fork 0
Support multiple validators, add "Using Validators" section #275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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 6d631f1
Capitalize "Validation"
alexander-yevsyukov 9ddcb0f
Fix the placement path
alexander-yevsyukov 1aabc21
Add `TimestampValidator`
alexander-yevsyukov e4d0a3f
Optimise imports
alexander-yevsyukov 14e04a9
Update the implementation path
alexander-yevsyukov e39cab0
Update the implementation path
alexander-yevsyukov 63cb5ea
Update the task on 3rd party message validation
alexander-yevsyukov f363431
Update the task on 3rd party message validation
alexander-yevsyukov 2353e9d
Update `_examples` ref.
alexander-yevsyukov 46da80e
Add text for "Validating third-party messages"
alexander-yevsyukov ca0c4ac
Add placeholders when reporting `Timestamp` violations
alexander-yevsyukov 75852bc
Add code fragment "core"
alexander-yevsyukov a6eb7c5
Rename the section "Validating third-party messages" to "Validating e…
alexander-yevsyukov 441db1a
Extract `implement-an-external-validator.md` document
alexander-yevsyukov 4247c7a
Adjust the intro text for `TimestampValidator` review
alexander-yevsyukov 54c22a2
Fix test suite class name
alexander-yevsyukov edcb7f1
Add details on the `TimestampValidator` implementation
alexander-yevsyukov 3ff579f
Update dependency reports
alexander-yevsyukov 1dc9b1a
Pull violation functions at the file level
alexander-yevsyukov 76c550a
Bump Validation -> `2.0.0-SNAPSHOT.400`
alexander-yevsyukov 8c459a0
Update dependency reports
alexander-yevsyukov bd0cddb
Add resource entry for `TimestampValidator`
alexander-yevsyukov 58b8f49
Improve property name
alexander-yevsyukov 4b89c8d
Extract reading discovered validators
alexander-yevsyukov 2bdb330
Extract separator for message validator lines
alexander-yevsyukov 6be579e
Consolidate composition and parsing under `MessageValidatorFile`
alexander-yevsyukov d7c5a45
Optimise imports
alexander-yevsyukov f06d46b
Load validators from resources
alexander-yevsyukov 76abea1
Update build time
alexander-yevsyukov c389323
Narrow down filtering of proto files
alexander-yevsyukov cf20056
Update build time
alexander-yevsyukov b10d703
Update `_examples` ref.
alexander-yevsyukov ff61c82
Optimise imports
alexander-yevsyukov 78edd47
Allow validators for local messages
alexander-yevsyukov 2488663
Remove outdated documentation statements
alexander-yevsyukov 74b767b
Add task document for `ValidatorRegistry`
alexander-yevsyukov 50852db
Add initial implementation of `ValidatorRegistry`
alexander-yevsyukov 3de40fb
Pull the extension to the file level
alexander-yevsyukov 46916ea
Obtain message class via type token
alexander-yevsyukov 0e14c09
Use qualified class names as keys in `ValidatorRegistry`
alexander-yevsyukov 348d1fe
Return `ConstraintViolation`s from `ValidatorRegistry.validate()`
alexander-yevsyukov 731ada7
Fix capitlization and punctuation
alexander-yevsyukov 381e548
Update build time
alexander-yevsyukov c8a8f1d
Update dependency reports
alexander-yevsyukov 789bffd
Use `ValidatorRegistry` for top-level and nested validation
alexander-yevsyukov 391541b
Update dependency reports
alexander-yevsyukov 8e3a60c
Document the code branch
alexander-yevsyukov 2e6ceb8
Archive done task
alexander-yevsyukov 14b7af5
Document parameters
alexander-yevsyukov a7b79ec
Update build time
alexander-yevsyukov eecfadf
Fix doc grammar
alexander-yevsyukov 0831084
Extract validation block into a var
alexander-yevsyukov 66420d4
Fail on invalid `Any`s, avoid comparison with empty list or map
alexander-yevsyukov 2c778f5
Improve test suite names
alexander-yevsyukov 014edef
Bump JUnit -> `6.0.3`
alexander-yevsyukov 7a165f4
Update dependency reports
alexander-yevsyukov cb40d40
Add support for the `validator` placeholder in reported violations
alexander-yevsyukov 102463f
Handle `validator` placeholder in assertions
alexander-yevsyukov 78ab847
Improve documentation of `VALIDATOR_PLACEHOLDER`
alexander-yevsyukov db1231e
Update the plan on describing validators
alexander-yevsyukov 496236b
Rewrite "external messages" section
alexander-yevsyukov 87c89b7
Archive the task
alexander-yevsyukov fa46047
Allow querying validators
alexander-yevsyukov 220457a
Add task item on creating a page for `ValidatorRegistry`
alexander-yevsyukov e55b684
Add page on using `ValidatorRegistry`
alexander-yevsyukov f430795
Allow using Java classes in `ValidatiorRegistry`
alexander-yevsyukov f133c28
Update jvm-runtime/src/main/kotlin/io/spine/validation/ValidatorRegis…
alexander-yevsyukov 41adca0
Update jvm-runtime/src/main/kotlin/io/spine/validation/Validator.kt
alexander-yevsyukov b00cdb6
Fix typo
alexander-yevsyukov 28c118b
Update build time
alexander-yevsyukov 0374848
Make `ValidatorRegistry` thread-safe
alexander-yevsyukov c171349
Archive the task
alexander-yevsyukov 61cf322
Avoid using reflection in tests
alexander-yevsyukov 4db6db7
Update build time
alexander-yevsyukov 09c63c6
Add the note on configuring AutoService
alexander-yevsyukov 2d8ade3
Avoid unused variable
alexander-yevsyukov d8fb452
Clarify when validators work
alexander-yevsyukov 09a9393
Fix titles and capitalization
alexander-yevsyukov 8e0fc4f
Narrow down use case description
alexander-yevsyukov 1a0d525
Add missing period and backticks
alexander-yevsyukov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
.agents/tasks/archive/rewrite-external-messages-section.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
alexander-yevsyukov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.