diff --git a/buildSrc/src/test/kotlin/io/spine/gradle/report/license/DependencyReportOutputTest.kt b/buildSrc/src/test/kotlin/io/spine/gradle/report/license/DependencyReportOutputTest.kt index b17c66f069..9c36b218bc 100644 --- a/buildSrc/src/test/kotlin/io/spine/gradle/report/license/DependencyReportOutputTest.kt +++ b/buildSrc/src/test/kotlin/io/spine/gradle/report/license/DependencyReportOutputTest.kt @@ -57,8 +57,6 @@ class DependencyReportOutputTest { @Test fun `write the generated POM under docs-dependencies`() { - projectDir.resolve("pom.xml").writeText("legacy POM") - PomGenerator.applyTo(project) project.tasks.named("generatePom").get() @@ -70,8 +68,6 @@ class DependencyReportOutputTest { @Test fun `merge license reports under docs-dependencies`() { - projectDir.resolve("dependencies.md").writeText("legacy report") - project.pluginManager.apply(BasePlugin::class.java) val subproject = subproject("sub") LicenseReporter.generateReportIn(subproject) diff --git a/config b/config index fbec334fc0..c3ab20a7fc 160000 --- a/config +++ b/config @@ -1 +1 @@ -Subproject commit fbec334fc0caa4bfd7f39aab0267ee058494fafa +Subproject commit c3ab20a7fc8cf1464ff45651a19935b5b7aeaea7 diff --git a/context/src/main/kotlin/io/spine/tools/validation/ErrorPlaceholder.kt b/context/src/main/kotlin/io/spine/tools/validation/ErrorPlaceholder.kt new file mode 100644 index 0000000000..5044d74ae1 --- /dev/null +++ b/context/src/main/kotlin/io/spine/tools/validation/ErrorPlaceholder.kt @@ -0,0 +1,78 @@ +/* + * 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 + * + * 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 + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.spine.tools.validation + +/** + * A template placeholder that can be used in error messages. + * + * Enumerates placeholder names that can be used within Protobuf definitions. + * Each validation option declares the supported placeholders. Take a look at + * `options.proto` for examples. + * + * The enum is used by the compiler model and Java renderer when validating and rendering + * built-in option error messages. + */ +@Deprecated( + message = "Please use `io.spine.validation.ErrorPlaceholder` instead.", + replaceWith = ReplaceWith("ErrorPlaceholder", "io.spine.validation.ErrorPlaceholder") +) +public enum class ErrorPlaceholder(public val value: String) { + + // Common placeholders. + FIELD_PATH("field.path"), + FIELD_VALUE("field.value"), + FIELD_TYPE("field.type"), + MESSAGE_TYPE("message.type"), + PARENT_TYPE("parent.type"), + + // Placeholders for the field options. + REGEX_PATTERN("regex.pattern"), + REGEX_MODIFIERS("regex.modifiers"), + GOES_COMPANION("goes.companion"), + FIELD_PROPOSED_VALUE("field.proposed_value"), + FIELD_DUPLICATES("field.duplicates"), + RANGE_VALUE("range.value"), + MAX_VALUE("max.value"), + MAX_OPERATOR("max.operator"), + MIN_VALUE("min.value"), + MIN_OPERATOR("min.operator"), + WHEN_IN("when.in"), + + // Placeholders for the `oneof` options. + GROUP_PATH("group.path"), + + // Placeholder for the message options. + REQUIRE_FIELDS("require.fields"); + + /** + * Converts this placeholder to its runtime counterpart. + */ + public fun toRuntime(): io.spine.validation.ErrorPlaceholder = + io.spine.validation.ErrorPlaceholder.valueOf(name) + + override fun toString(): String = value +} diff --git a/docs/_examples b/docs/_examples index 3bc72870cc..0857c90894 160000 --- a/docs/_examples +++ b/docs/_examples @@ -1 +1 @@ -Subproject commit 3bc72870cc60d3358a4a5b054ee1313d30319412 +Subproject commit 0857c90894b6f4a4caf12408088c6b59768110ce diff --git a/docs/content/docs/validation/developer/build-and-release.md b/docs/content/docs/validation/developer/build-and-release.md index 6ef2ecc511..dc0ca90609 100644 --- a/docs/content/docs/validation/developer/build-and-release.md +++ b/docs/content/docs/validation/developer/build-and-release.md @@ -47,7 +47,7 @@ through Gradle's `extra` properties: end="val validationVersion"> ```kotlin -val validationVersion by extra("2.0.0-SNAPSHOT.420") +val validationVersion by extra("2.0.0-SNAPSHOT.421") ``` The root build script applies this file under `allprojects { … }` and assigns diff --git a/docs/content/docs/validation/user/01-getting-started/adding-to-build.md b/docs/content/docs/validation/user/01-getting-started/adding-to-build.md index d5bf9d49fc..ab88f3805d 100644 --- a/docs/content/docs/validation/user/01-getting-started/adding-to-build.md +++ b/docs/content/docs/validation/user/01-getting-started/adding-to-build.md @@ -90,7 +90,7 @@ Add the Validation plugin to the build. ```kotlin plugins { module - id("io.spine.validation") version "2.0.0-SNAPSHOT.420" + id("io.spine.validation") version "2.0.0-SNAPSHOT.421" } ``` diff --git a/docs/dependencies/dependencies.md b/docs/dependencies/dependencies.md index 041de692fe..1e01107cbe 100644 --- a/docs/dependencies/dependencies.md +++ b/docs/dependencies/dependencies.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine.tools:validation-context:2.0.0-SNAPSHOT.420` +# Dependencies of `io.spine.tools:validation-context:2.0.0-SNAPSHOT.421` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -1090,14 +1090,14 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed May 13 20:44:36 WEST 2026** using +This report was generated on **Thu May 14 20:38:23 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:validation-context-tests:2.0.0-SNAPSHOT.420` +# Dependencies of `io.spine.tools:validation-context-tests:2.0.0-SNAPSHOT.421` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -1791,7 +1791,7 @@ This report was generated on **Wed May 13 20:44:36 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed May 13 20:44:36 WEST 2026** using +This report was generated on **Thu May 14 20:38:22 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -1812,7 +1812,7 @@ This report was generated on **Wed May 13 20:09:04 WEST 2026** using -# Dependencies of `io.spine.tools:validation-gradle-plugin:2.0.0-SNAPSHOT.420` +# Dependencies of `io.spine.tools:validation-gradle-plugin:2.0.0-SNAPSHOT.421` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -2864,14 +2864,14 @@ This report was generated on **Wed May 13 20:09:04 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed May 13 20:44:36 WEST 2026** using +This report was generated on **Thu May 14 20:38:23 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:validation-java:2.0.0-SNAPSHOT.420` +# Dependencies of `io.spine.tools:validation-java:2.0.0-SNAPSHOT.421` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -3961,14 +3961,14 @@ This report was generated on **Wed May 13 20:44:36 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed May 13 20:44:36 WEST 2026** using +This report was generated on **Thu May 14 20:38:23 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:validation-java-bundle:2.0.0-SNAPSHOT.420` +# Dependencies of `io.spine.tools:validation-java-bundle:2.0.0-SNAPSHOT.421` ## Runtime 1. **Group** : org.jetbrains. **Name** : annotations. **Version** : 13.0. @@ -4015,14 +4015,14 @@ This report was generated on **Wed May 13 20:44:36 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed May 13 20:44:35 WEST 2026** using +This report was generated on **Thu May 14 20:38:19 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-validation-jvm-runtime:2.0.0-SNAPSHOT.420` +# Dependencies of `io.spine:spine-validation-jvm-runtime:2.0.0-SNAPSHOT.421` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -4822,14 +4822,14 @@ This report was generated on **Wed May 13 20:44:35 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed May 13 20:44:36 WEST 2026** using +This report was generated on **Thu May 14 20:38:23 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:validation-consumer:2.0.0-SNAPSHOT.420` +# Dependencies of `io.spine.tools:validation-consumer:2.0.0-SNAPSHOT.421` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -5511,14 +5511,14 @@ This report was generated on **Wed May 13 20:44:36 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed May 13 20:44:36 WEST 2026** using +This report was generated on **Thu May 14 20:38:22 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:validation-consumer-dependency:2.0.0-SNAPSHOT.420` +# Dependencies of `io.spine.tools:validation-consumer-dependency:2.0.0-SNAPSHOT.421` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -5976,14 +5976,14 @@ This report was generated on **Wed May 13 20:44:36 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed May 13 20:44:36 WEST 2026** using +This report was generated on **Thu May 14 20:38:22 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:validation-extensions:2.0.0-SNAPSHOT.420` +# Dependencies of `io.spine.tools:validation-extensions:2.0.0-SNAPSHOT.421` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -6602,14 +6602,14 @@ This report was generated on **Wed May 13 20:44:36 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed May 13 20:44:36 WEST 2026** using +This report was generated on **Thu May 14 20:38:21 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:validation-runtime:2.0.0-SNAPSHOT.420` +# Dependencies of `io.spine.tools:validation-runtime:2.0.0-SNAPSHOT.421` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -7170,14 +7170,14 @@ This report was generated on **Wed May 13 20:44:36 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed May 13 20:44:36 WEST 2026** using +This report was generated on **Thu May 14 20:38:22 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:validation-validating:2.0.0-SNAPSHOT.420` +# Dependencies of `io.spine.tools:validation-validating:2.0.0-SNAPSHOT.421` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -7781,14 +7781,14 @@ This report was generated on **Wed May 13 20:44:36 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed May 13 20:44:36 WEST 2026** using +This report was generated on **Thu May 14 20:38:22 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:validation-validator:2.0.0-SNAPSHOT.420` +# Dependencies of `io.spine.tools:validation-validator:2.0.0-SNAPSHOT.421` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -8526,14 +8526,14 @@ This report was generated on **Wed May 13 20:44:36 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed May 13 20:44:36 WEST 2026** using +This report was generated on **Thu May 14 20:38:22 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:validation-validator-dependency:2.0.0-SNAPSHOT.420` +# Dependencies of `io.spine.tools:validation-validator-dependency:2.0.0-SNAPSHOT.421` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -8766,14 +8766,14 @@ This report was generated on **Wed May 13 20:44:36 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed May 13 20:44:35 WEST 2026** using +This report was generated on **Thu May 14 20:38:21 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:validation-vanilla:2.0.0-SNAPSHOT.420` +# Dependencies of `io.spine.tools:validation-vanilla:2.0.0-SNAPSHOT.421` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -9116,6 +9116,6 @@ This report was generated on **Wed May 13 20:44:35 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed May 13 20:44:35 WEST 2026** using +This report was generated on **Thu May 14 20:38:21 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file diff --git a/docs/dependencies/pom.xml b/docs/dependencies/pom.xml index c57129ad5c..133b9969ac 100644 --- a/docs/dependencies/pom.xml +++ b/docs/dependencies/pom.xml @@ -10,7 +10,7 @@ all modules and does not describe the project structure per-subproject. --> io.spine.tools validation -2.0.0-SNAPSHOT.420 +2.0.0-SNAPSHOT.421 2015 diff --git a/java/src/main/kotlin/io/spine/tools/validation/java/expression/TemplateStrings.kt b/java/src/main/kotlin/io/spine/tools/validation/java/expression/TemplateStrings.kt index 9ce5f69c58..3314aa9de0 100644 --- a/java/src/main/kotlin/io/spine/tools/validation/java/expression/TemplateStrings.kt +++ b/java/src/main/kotlin/io/spine/tools/validation/java/expression/TemplateStrings.kt @@ -1,5 +1,5 @@ /* - * Copyright 2025, 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. @@ -47,6 +47,7 @@ import io.spine.validation.checkPlaceholdersHasValue * @param placeholders The supported placeholders and their values. * @param optionName The name of the option, which declared the provided [placeholders]. */ +@JvmName("templateStringExp") public fun templateString( template: String, placeholders: Map>, @@ -54,6 +55,32 @@ public fun templateString( ): Expression = withStringPlaceholders(template, placeholders.mapKeys { it.key.value }, optionName) +/** + * Yields an expression that creates a new instance of [TemplateString]. + * + * This overload accepts the deprecated placeholders from the former + * `io.spine.tools.validation` package. + * + * @param placeholders The supported placeholders and their values. + * @param optionName The name of the option, which declared the provided [placeholders]. + */ +@Suppress("DEPRECATION") +@Deprecated( + message = "Please use the overload accepting `io.spine.validation.ErrorPlaceholder`." +) +public fun templateString( + template: String, + placeholders: Map>, + optionName: String +): Expression { + val runtimePlaceholders = placeholders.mapKeys { it.key.toRuntime() } + return withStringPlaceholders( + template, + runtimePlaceholders.mapKeys { it.key.value }, + optionName + ) +} + /** * Yields an expression that creates a new instance of [TemplateString]. * diff --git a/jvm-runtime/src/main/kotlin/io/spine/validation/ErrorPlaceholder.kt b/jvm-runtime/src/main/kotlin/io/spine/validation/ErrorPlaceholder.kt index 7b37035a19..f2a6bd5ad9 100644 --- a/jvm-runtime/src/main/kotlin/io/spine/validation/ErrorPlaceholder.kt +++ b/jvm-runtime/src/main/kotlin/io/spine/validation/ErrorPlaceholder.kt @@ -56,6 +56,8 @@ public enum class ErrorPlaceholder(public val value: String) { MAX_OPERATOR("max.operator"), MIN_VALUE("min.value"), MIN_OPERATOR("min.operator"), + + @Deprecated(message = "Use the placeholder reference from Spine Time instead.") WHEN_IN("when.in"), // Placeholders for the `oneof` options. diff --git a/version.gradle.kts b/version.gradle.kts index ee62bd3168..82a46bd6ca 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -27,4 +27,4 @@ /** * The version of the Validation library to publish. */ -val validationVersion by extra("2.0.0-SNAPSHOT.420") +val validationVersion by extra("2.0.0-SNAPSHOT.421")