Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
56 changes: 28 additions & 28 deletions dependencies.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


# Dependencies of `io.spine.validation:spine-validation-java:2.0.0-SNAPSHOT.315`
# Dependencies of `io.spine.validation:spine-validation-java:2.0.0-SNAPSHOT.316`

## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3.
Expand Down Expand Up @@ -861,12 +861,12 @@

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Mon Apr 28 12:48:59 CEST 2025** 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).
This report was generated on **Mon Apr 28 17:30:05 CEST 2025** 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.validation:spine-validation-java-bundle:2.0.0-SNAPSHOT.315`
# Dependencies of `io.spine.validation:spine-validation-java-bundle:2.0.0-SNAPSHOT.316`

## Runtime
1. **Group** : org.jetbrains. **Name** : annotations. **Version** : 26.0.2.
Expand Down Expand Up @@ -1466,12 +1466,12 @@ This report was generated on **Mon Apr 28 12:48:59 CEST 2025** using [Gradle-Lic

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Mon Apr 28 12:48:59 CEST 2025** 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).
This report was generated on **Mon Apr 28 17:30:05 CEST 2025** 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.validation:spine-validation-java-runtime:2.0.0-SNAPSHOT.315`
# Dependencies of `io.spine.validation:spine-validation-java-runtime:2.0.0-SNAPSHOT.316`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -2154,12 +2154,12 @@ This report was generated on **Mon Apr 28 12:48:59 CEST 2025** using [Gradle-Lic

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Mon Apr 28 12:48:59 CEST 2025** 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).
This report was generated on **Mon Apr 28 17:30:05 CEST 2025** 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.validation:spine-validation-java-tests:2.0.0-SNAPSHOT.315`
# Dependencies of `io.spine.validation:spine-validation-java-tests:2.0.0-SNAPSHOT.316`

## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3.
Expand Down Expand Up @@ -3128,12 +3128,12 @@ This report was generated on **Mon Apr 28 12:48:59 CEST 2025** using [Gradle-Lic

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Mon Apr 28 12:49:00 CEST 2025** 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).
This report was generated on **Mon Apr 28 17:30:05 CEST 2025** 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.validation:spine-validation-model:2.0.0-SNAPSHOT.315`
# Dependencies of `io.spine.validation:spine-validation-model:2.0.0-SNAPSHOT.316`

## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3.
Expand Down Expand Up @@ -4018,12 +4018,12 @@ This report was generated on **Mon Apr 28 12:49:00 CEST 2025** using [Gradle-Lic

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Mon Apr 28 12:49:00 CEST 2025** 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).
This report was generated on **Mon Apr 28 17:30:06 CEST 2025** 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.validation:spine-validation-proto:2.0.0-SNAPSHOT.315`
# Dependencies of `io.spine.validation:spine-validation-proto:2.0.0-SNAPSHOT.316`

## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3.
Expand Down Expand Up @@ -4972,12 +4972,12 @@ This report was generated on **Mon Apr 28 12:49:00 CEST 2025** using [Gradle-Lic

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Mon Apr 28 12:49:00 CEST 2025** 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).
This report was generated on **Mon Apr 28 17:30:06 CEST 2025** 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.validation:spine-validation-consumer:2.0.0-SNAPSHOT.315`
# Dependencies of `io.spine.validation:spine-validation-consumer:2.0.0-SNAPSHOT.316`

## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3.
Expand Down Expand Up @@ -5862,12 +5862,12 @@ This report was generated on **Mon Apr 28 12:49:00 CEST 2025** using [Gradle-Lic

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Mon Apr 28 12:49:00 CEST 2025** 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).
This report was generated on **Mon Apr 28 17:30:06 CEST 2025** 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.validation:spine-validation-consumer-dependency:2.0.0-SNAPSHOT.315`
# Dependencies of `io.spine.validation:spine-validation-consumer-dependency:2.0.0-SNAPSHOT.316`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -6679,12 +6679,12 @@ This report was generated on **Mon Apr 28 12:49:00 CEST 2025** using [Gradle-Lic

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Mon Apr 28 12:49:01 CEST 2025** 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).
This report was generated on **Mon Apr 28 17:30:06 CEST 2025** 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.validation:spine-validation-extensions:2.0.0-SNAPSHOT.315`
# Dependencies of `io.spine.validation:spine-validation-extensions:2.0.0-SNAPSHOT.316`

## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3.
Expand Down Expand Up @@ -7617,12 +7617,12 @@ This report was generated on **Mon Apr 28 12:49:01 CEST 2025** using [Gradle-Lic

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Mon Apr 28 12:49:01 CEST 2025** 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).
This report was generated on **Mon Apr 28 17:30:07 CEST 2025** 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.validation:spine-validation-runtime:2.0.0-SNAPSHOT.315`
# Dependencies of `io.spine.validation:spine-validation-runtime:2.0.0-SNAPSHOT.316`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -8450,12 +8450,12 @@ This report was generated on **Mon Apr 28 12:49:01 CEST 2025** using [Gradle-Lic

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Mon Apr 28 12:49:01 CEST 2025** 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).
This report was generated on **Mon Apr 28 17:30:07 CEST 2025** 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.validation:spine-validation-validating:2.0.0-SNAPSHOT.315`
# Dependencies of `io.spine.validation:spine-validation-validating:2.0.0-SNAPSHOT.316`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -9287,12 +9287,12 @@ This report was generated on **Mon Apr 28 12:49:01 CEST 2025** using [Gradle-Lic

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Mon Apr 28 12:49:01 CEST 2025** 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).
This report was generated on **Mon Apr 28 17:30:07 CEST 2025** 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.validation:spine-validation-vanilla:2.0.0-SNAPSHOT.315`
# Dependencies of `io.spine.validation:spine-validation-vanilla:2.0.0-SNAPSHOT.316`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -10056,12 +10056,12 @@ This report was generated on **Mon Apr 28 12:49:01 CEST 2025** using [Gradle-Lic

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Mon Apr 28 12:49:01 CEST 2025** 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).
This report was generated on **Mon Apr 28 17:30:07 CEST 2025** 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.validation:spine-validation-configuration:2.0.0-SNAPSHOT.315`
# Dependencies of `io.spine.validation:spine-validation-configuration:2.0.0-SNAPSHOT.316`

## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3.
Expand Down Expand Up @@ -10994,12 +10994,12 @@ This report was generated on **Mon Apr 28 12:49:01 CEST 2025** using [Gradle-Lic

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Mon Apr 28 12:49:02 CEST 2025** 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).
This report was generated on **Mon Apr 28 17:30:07 CEST 2025** 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.validation:spine-validation-context:2.0.0-SNAPSHOT.315`
# Dependencies of `io.spine.validation:spine-validation-context:2.0.0-SNAPSHOT.316`

## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3.
Expand Down Expand Up @@ -11932,4 +11932,4 @@ This report was generated on **Mon Apr 28 12:49:02 CEST 2025** using [Gradle-Lic

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Mon Apr 28 12:49:02 CEST 2025** 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).
This report was generated on **Mon Apr 28 17:30:07 CEST 2025** 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).
31 changes: 25 additions & 6 deletions model/src/main/kotlin/io/spine/validation/ChoiceOption.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
` * Copyright 2024, TeamDev. All rights reserved.
* Copyright 2025, 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.
Expand Down Expand Up @@ -43,15 +43,26 @@ import io.spine.server.event.NoReaction
import io.spine.server.event.React
import io.spine.server.event.asA
import io.spine.server.tuple.EitherOf2
import io.spine.validation.ErrorPlaceholder.GROUP_PATH
import io.spine.validation.ErrorPlaceholder.PARENT_TYPE
import io.spine.validation.event.ChoiceOneofDiscovered
import io.spine.validation.event.choiceOneofDiscovered

/**
* Controls whether a `oneof` group should be validated with the `(choice)` option.
*
* Whenever a `oneof` groupd marked with `(choice)` option is discovered,
* emits [ChoiceOneofDiscovered] event if the option has the `required` flag
* set to `true`. Otherwise, the policy emits [NoReaction].
* Whenever a `oneof` groupd marked with the `(choice)` option is discovered,
* emits [ChoiceOneofDiscovered] event if the following conditions are met:
*
* 1. The option has the `required` flag set to `true`.
* 2. The error message does not contain unsupported placeholders.
*
* Violation of (1) means that the `(choice)` option is applied correctly,
* but effectively disabled. [ChoiceOneofDiscovered] is not emitted for
* disabled options. In this case, the policy emits [NoReaction] meaning
* that the option is ignored.
*
* Violation of (2) leads to a compilation error.
*
* Note that unlike the `(required)` constraint, this option supports any field type.
* Protobuf encodes a non-set value as a special case, allowing for checking whether
Expand All @@ -64,13 +75,16 @@ internal class ChoicePolicy : Policy<OneofOptionDiscovered>() {
@External @Where(field = OPTION_NAME, equals = CHOICE)
event: OneofOptionDiscovered
): EitherOf2<ChoiceOneofDiscovered, NoReaction> {
val oneof = event.subject
val file = event.file
val option = event.option.unpack<ChoiceOption>()
val message = option.errorMsg.ifEmpty { option.descriptorForType.defaultMessage }
message.checkPlaceholders(SUPPORTED_PLACEHOLDERS, oneof, file, CHOICE)

if (!option.required) {
return ignore()
}

val oneof = event.subject
val message = option.errorMsg.ifEmpty { option.descriptorForType.defaultMessage }
return choiceOneofDiscovered {
id = oneof.ref
subject = oneof
Expand Down Expand Up @@ -108,3 +122,8 @@ internal class ChoiceGroupView : View<OneofRef, ChoiceOneof, ChoiceOneof.Builder
errorMessage = e.errorMessage
}
}

private val SUPPORTED_PLACEHOLDERS = setOf(
GROUP_PATH,
PARENT_TYPE,
)
26 changes: 11 additions & 15 deletions model/src/main/kotlin/io/spine/validation/DistinctOption.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ import io.spine.validation.event.ifHasDuplicatesOptionDiscovered
* If (1) is violated, the policy reports a compilation error.
*
* Violation of (2) means that the `(distinct)` option is applied correctly,
* but disabled. In this case, the policy emits [NoReaction] because we
* actually have a non-distinct field, marked with `(distinct)`.
* but effectively disabled. [DistinctFieldDiscovered] is not emitted for
* disabled options. In this case, the policy emits [NoReaction] meaning
* that the option is ignored.
*/
internal class DistinctPolicy : Policy<FieldOptionDiscovered>() {

Expand Down Expand Up @@ -129,7 +130,7 @@ internal class IfHasDuplicatesPolicy : Policy<FieldOptionDiscovered>() {

val option = event.option.unpack<IfHasDuplicatesOption>()
val message = option.errorMsg
checkPlaceholders(message, field, file)
message.checkPlaceholders(SUPPORTED_PLACEHOLDERS, field, file, IF_HAS_DUPLICATES)

return ifHasDuplicatesOptionDiscovered {
id = field.ref
Expand Down Expand Up @@ -170,15 +171,10 @@ private fun checkFieldType(field: Field, file: File) =
*/
private fun FieldType.isSupported(): Boolean = isMap || isList

private fun checkPlaceholders(template: String, field: Field, file: File) {
val missing = missingPlaceholders(template, SUPPORTED_PLACEHOLDERS)
Compilation.check(missing.isEmpty(), file, field.span) {
"The `${field.qualifiedName}` field specifies an error message using" +
" the `($IF_HAS_DUPLICATES)` option with unsupported placeholders: `$missing`." +
" Supported placeholders are the following:" +
" `${SUPPORTED_PLACEHOLDERS.map { it.value }}`."
}
}

private val SUPPORTED_PLACEHOLDERS =
setOf(FIELD_PATH, FIELD_VALUE, FIELD_TYPE, PARENT_TYPE, FIELD_DUPLICATES)
private val SUPPORTED_PLACEHOLDERS = setOf(
FIELD_DUPLICATES,
FIELD_PATH,
FIELD_TYPE,
FIELD_VALUE,
PARENT_TYPE,
)
24 changes: 0 additions & 24 deletions model/src/main/kotlin/io/spine/validation/ErrorPlaceholder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

package io.spine.validation

import io.spine.validate.extractPlaceholders

/**
* A template placeholder that can be used in error messages.
*
Expand Down Expand Up @@ -76,25 +74,3 @@ public enum class ErrorPlaceholder(public val value: String) {

override fun toString(): String = value
}

/**
* Returns a set of placeholders that are used by the given [template] string,
* but not present in the provided [placeholders] set.
*
* @param template The template with placeholders like `${something}`.
* @param placeholders The set of error placeholders.
*/
public fun missingPlaceholders(
template: String,
placeholders: Set<ErrorPlaceholder>
): Set<String> {
val requested = extractPlaceholders(template)
val provided = placeholders.map { it.value }
val missing = mutableSetOf<String>()
for (placeholder in requested) {
if (!provided.contains(placeholder)) {
missing.add(placeholder)
}
}
return missing
}
Loading
Loading