Migrate to TemplateString from Spine Base#303
Conversation
Migrate `TemplateString` Protobuf message, the `Placeholder` interface, and the general-purpose template string extensions from `jvm-runtime` to the `io.spine.string` package in the `base` module. Validation-specific extensions (`withField`, `withCompanion`, `withRegex`) stay here. Follow-up: the upstream `core-jvm-compiler-plugin` still emits `io.spine.validation.TemplateString.newBuilder()` into generated Java for `:context`'s own option messages. Republishing the compiler plugin against the new base is required to unblock `:context:compileJava`.
There was a problem hiding this comment.
Pull request overview
Migrates the validation library from its internal TemplateString/Placeholder types to the equivalents now provided by Spine Base (io.spine.string.TemplateString, io.spine.string.Placeholder). The rename of the runtime placeholder enum from ErrorPlaceholder to StandardPlaceholder is applied across model, generators, runtime, tests, and docs. A new (currently disabled) :tests:time module is added as a placeholder for future Spine Time integration tests, and the relevant Spine Base/Time/CoreJvmCompiler dependency versions are bumped.
Changes:
- Replace internal
io.spine.validation.TemplateString/format/formatUnsafe/extractPlaceholders/checkPlaceholdersHasValuewith theio.spine.stringequivalents from Spine Base; delete the now-supersedederror_message.proto,TemplateStringExtsSpec, and the deprecated context-sideErrorPlaceholder. - Rename
ErrorPlaceholder→StandardPlaceholder(implementingio.spine.string.Placeholder), keep a deprecatedRuntimeErrorPlaceholdertypealias, and propagateMap<Placeholder, Expression<String>>signatures through generators and the SetOnce constraint builder. - Add the new
:tests:timemodule (build script, proto definitions, fixtures, assertions, and@DisabledTimestamp/Temporal(when)specs), bumpBaseto SNAPSHOT.388,Timeto SNAPSHOT.240,CoreJvmCompilerdogfooding to SNAPSHOT.064, and refresh the dependency report.
Reviewed changes
Copilot reviewed 69 out of 69 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| jvm-runtime/src/main/proto/spine/validation/error_message.proto | Removed; TemplateString now sourced from spine/string/template_string.proto. |
| jvm-runtime/src/main/proto/spine/validation/validation_error.proto | Switches ConstraintViolation.message to spine.string.TemplateString and updates the Java helper class reference. |
| jvm-runtime/src/main/kotlin/io/spine/validation/StandardPlaceholder.kt | Renames the enum, makes it implement Placeholder, updates the deprecated typealias. |
| jvm-runtime/src/main/kotlin/io/spine/validation/TemplateStringExts.kt | Drops local format/formatUnsafe/extractPlaceholders/checkPlaceholdersHasValue; keeps validation-specific builder helpers. |
| jvm-runtime/src/main/kotlin/io/spine/validation/{TimestampValidator,DetectedViolation,ValidatorRegistry}.kt | Re-imports TemplateString/templateString and StandardPlaceholder from new locations. |
| jvm-runtime/src/main/java/io/spine/validation/ViolationText.java | Imports format from io.spine.string.TemplateStrings. |
| jvm-runtime/src/test/kotlin/io/spine/validation/TemplateStringExtsSpec.kt | Removed (functionality moved to Spine Base). |
| jvm-runtime/src/test/kotlin/io/spine/validation/{ValidatorRegistrySpec,given/TemplateStrings}.kt | Updated imports. |
| context/src/main/kotlin/io/spine/tools/validation/ErrorPlaceholder.kt | Removed deprecated context-side enum. |
| context/src/main/kotlin/io/spine/tools/validation/ErrorPlaceholders.kt | Switches signatures to Set<Placeholder> and uses extractPlaceholders from Spine Base. |
| context/src/main/kotlin/io/spine/tools/validation/option/{ChoiceOption,DistinctOption,GoesOption,PatternOption,RequireOption,SetOnceOption,required/RequiredOption}.kt | Update imports to StandardPlaceholder. |
| context/src/main/kotlin/io/spine/tools/validation/bound/{MaxOption,MinOption,RangeOption}.kt | Same StandardPlaceholder import update. |
| java/src/main/kotlin/io/spine/tools/validation/java/expression/{TemplateStrings,ConstraintViolations,ClassNames}.kt | Switch to Placeholder/TemplateString from io.spine.string; remove deprecated overload accepting context-side ErrorPlaceholder. |
| java/src/main/kotlin/io/spine/tools/validation/java/generate/{ValidatorGenerator,option/*Generator,option/bound/*Generator}.kt | Use Placeholder typed maps and StandardPlaceholder constants. |
| java/src/main/kotlin/io/spine/tools/validation/java/setonce/SetOnceConstraintViolation.kt | Same migration to Placeholder/StandardPlaceholder. |
| tests/consumer/build.gradle.kts | Wraps duplicate :tests:extensions dependency declaration with a suppression. |
| tests/consumer/src/test/kotlin/.../{ErrorMessageSpec,MinRuleITest,PatternRuleITest,RequiredRuleITest,ValidateRuleITest}.kt | Import format/formatUnsafe from io.spine.string. |
| tests/runtime/src/test/kotlin/io/spine/validation/option/ChoiceSpec.kt | Same format import update. |
| tests/validating/src/testFixtures/.../Assertions.kt and src/test/kotlin/.../{NumberConstraintsITest,RequireITest,ChoiceITest,goes/GoesViolationITest,setonce/SetOnceViolationITest}.kt | Update imports to io.spine.string helpers and StandardPlaceholder. |
| tests/validator/src/main/kotlin/.../{EarphonesValidator,TheOnlyTimeValid}.kt | Use TemplateString/templateString from io.spine.string. |
| tests/vanilla/src/test/kotlin/.../IsRequiredSpec.kt | Update format import. |
| settings.gradle.kts | Includes the new :tests:time subproject. |
| tests/time/build.gradle.kts | New build script wiring io.spine.time plugin and validation compiler plugins. |
| tests/time/src/test/proto/spine/test/validation/time/when.proto | New proto fixtures with (when) PAST/FUTURE messages for both Protobuf Timestamp and Spine LocalDateTime. |
| tests/time/src/test/kotlin/.../{Assertions,Fixtures,TimestampWhenSpec,TemporalWhenSpec}.kt | New test helpers and @Disabled specs awaiting Spine Time migration to the new Placeholder API. |
| docs/content/docs/validation/developer/{validation-model,runtime-library,adding-a-built-in-option}.md | Update documentation references from ErrorPlaceholder to StandardPlaceholder/Placeholder. |
| docs/dependencies/{pom.xml,dependencies.md} | Refresh dependency manifest and license report (adds spine-time-java, version bumps, new validation-time module section). |
| buildSrc/src/main/kotlin/io/spine/dependency/local/{Base,Time,CoreJvmCompiler}.kt | Bump Spine Base, Time, and CoreJvmCompiler dogfooding versions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ba82d5448a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
We want to avoid importing the function from the previous version of Validation runtime.
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
armiol
left a comment
There was a problem hiding this comment.
@alexander-yevsyukov LGTM once the checks pass.
This PR migrates Validation to use
TemplateStringandPlaceholderfrom Spine Base. This is the next step in improving the extensibility of working with placeholders in libraries that extend Validation.The build was extended with the temporary tasks that patch the code generated for Protobuf types in
jvm-runtimeandcontextmodules. The code replaces references toio.spine.validation.TemplateStringand associated types to those belonging to theio.spine.stringpackage from Base.