Skip to content

Commit

Permalink
Merge pull request #846 from SpineEventEngine/use-kotlin-templates
Browse files Browse the repository at this point in the history
Use Kotlin-like placeholder in error message templates
  • Loading branch information
yevhenii-nadtochii authored Dec 20, 2024
2 parents 89e016b + 4ca90c8 commit f4e6ddc
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 65 deletions.
4 changes: 2 additions & 2 deletions dependencies.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


# Dependencies of `io.spine:spine-base:2.0.0-SNAPSHOT.233`
# Dependencies of `io.spine:spine-base:2.0.0-SNAPSHOT.234`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -845,4 +845,4 @@

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

This report was generated on **Wed Dec 18 17:20:44 CET 2024** 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 **Fri Dec 20 11:30:40 CET 2024** 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).
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ all modules and does not describe the project structure per-subproject.
-->
<groupId>io.spine</groupId>
<artifactId>base</artifactId>
<version>2.0.0-SNAPSHOT.233</version>
<version>2.0.0-SNAPSHOT.234</version>

<inceptionYear>2015</inceptionYear>

Expand Down
122 changes: 61 additions & 61 deletions src/main/proto/spine/options.proto
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ extend google.protobuf.MessageOptions {
// ```
// message GoesOption {
// // The default error message.
// option (default_message) = "The field `{goes.companion}` must also be set when `{field.name}` is set.";
// option (default_message) = "The field `${goes.companion}` must also be set when `${field.name}` is set.";
// }
// ```
//
Expand Down Expand Up @@ -650,7 +650,7 @@ extend google.protobuf.ServiceOptions {
message IfMissingOption {

// The default error message.
option (default_message) = "The field `{parent.type}.{field.name}` of the type `{field.type}` must have a value.";
option (default_message) = "The field `${parent.type}.${field.name}` of the type `${field.type}` must have a value.";

// A user-defined validation error format message.
//
Expand All @@ -662,17 +662,17 @@ message IfMissingOption {
//
// The specified message may include the following placeholders:
//
// 1. `{field.name}` – the field name.
// 2. `{field.type}` – the fully qualified name of the field type.
// 3. `{parent.type}` – the fully qualified name of the field declaring type.
// 1. `${field.name}` – the field name.
// 2. `${field.type}` – the fully qualified name of the field type.
// 3. `${parent.type}` – the fully qualified name of the field declaring type.
//
// The placeholders will be replaced at runtime when the error is constructed.
//
// Example: Using the `(if_missing)` option.
//
// message Student {
// Name name = 1 [(required) = true,
// (if_missing).error_msg = "The `{field.name}` field is mandatory for `{parent.type}`."];
// (if_missing).error_msg = "The `${field.name}` field is mandatory for `${parent.type}`."];
// }
//
string error_msg = 2;
Expand All @@ -689,14 +689,14 @@ message IfMissingOption {
// double value = 1 [(min) = {
// value: "0.0",
// exclusive: true,
// error_msg: "The temperature cannot reach `{min.value}K`, but provided `{field.value}`."
// error_msg: "The temperature cannot reach `${min.value}K`, but provided `${field.value}`."
// }];
// }
//
message MinOption {

// The default error message.
option (default_message) = "The field `{parent.type}.{field.name}` must be {max.operator} {min.value}.";
option (default_message) = "The field `${parent.type}.${field.name}` must be ${max.operator} ${min.value}.";

// The string representation of the minimum field value.
string value = 1;
Expand All @@ -714,12 +714,12 @@ message MinOption {
//
// The specified message may include the following placeholders:
//
// 1. `{field.value}` - the field value.
// 2. `{field.name}` – the field name.
// 3. `{field.type}` – the fully qualified name of the field type.
// 4. `{parent.type}` – the fully qualified name of the field declaring type.
// 5. `{min.value}` – the specified minimum `value`.
// 6. `{min.operator}` – if `exclusive` is set to `true`, this placeholder equals to ">".
// 1. `${field.value}` - the field value.
// 2. `${field.name}` – the field name.
// 3. `${field.type}` – the fully qualified name of the field type.
// 4. `${parent.type}` – the fully qualified name of the field declaring type.
// 5. `${min.value}` – the specified minimum `value`.
// 6. `${min.operator}` – if `exclusive` is set to `true`, this placeholder equals to ">".
// Otherwise, ">=".
//
// The placeholders will be replaced at runtime when the error is constructed.
Expand All @@ -736,13 +736,13 @@ message MinOption {
//
// message TowerCrane {
// double load = 1 [(max).value = "4.2",
// (max).error_msg = "The crane load in `{parent.type}` can not exceed `{max.value}` tons, but provided `{field.value}`."];
// (max).error_msg = "The crane load in `${parent.type}` can not exceed `${max.value}` tons, but provided `${field.value}`."];
// }
//
message MaxOption {

// The default error message.
option (default_message) = "The field `{parent.type}.{field.name}` must be {max.operator} {max.value}.";
option (default_message) = "The field `${parent.type}.${field.name}` must be ${max.operator} ${max.value}.";

// The string representation of the maximum field value.
string value = 1;
Expand All @@ -760,12 +760,12 @@ message MaxOption {
//
// The specified message may include the following placeholders:
//
// 1. `{field.name}` – the field name.
// 2. `{field.value}` - the field value.
// 3. `{field.type}` – the fully qualified name of the field type.
// 4. `{parent.type}` – the fully qualified name of the field declaring type.
// 5. `{max.value}` – the specified maximum `value`.
// 6. `{max.operator}` – if `exclusive` is set to `true`, this placeholder equals to "<".
// 1. `${field.name}` – the field name.
// 2. `${field.value}` - the field value.
// 3. `${field.type}` – the fully qualified name of the field type.
// 4. `${parent.type}` – the fully qualified name of the field declaring type.
// 5. `${max.value}` – the specified maximum `value`.
// 6. `${max.operator}` – if `exclusive` is set to `true`, this placeholder equals to "<".
// Otherwise, "<=".
//
// The placeholders will be replaced at runtime when the error is constructed.
Expand All @@ -782,13 +782,13 @@ message MaxOption {
//
// message CreateAccount {
// string id = 1 [(pattern).regex = "^[A-Za-z0-9+]+$",
// (pattern).error_msg = "ID must be alphanumerical in `{parent.type}`. Provided: `{field.value}`."];
// (pattern).error_msg = "ID must be alphanumerical in `${parent.type}`. Provided: `${field.value}`."];
// }
//
message PatternOption {

// The default error message.
option (default_message) = "The `{parent.type}.{field.name}` field must match the regular expression `{regex.pattern}` (modifiers: `{regex.modifiers}`). The passed value: `{field.value}`.";
option (default_message) = "The `${parent.type}.${field.name}` field must match the regular expression `${regex.pattern}` (modifiers: `${regex.modifiers}`). The passed value: `${field.value}`.";

// The regular expression to match.
string regex = 1;
Expand All @@ -806,12 +806,12 @@ message PatternOption {
//
// The specified message may include the following placeholders:
//
// 1. `{field.name}` – the field name.
// 2. `{field.value}` - the field value.
// 3. `{field.type}` – the fully qualified name of the field type.
// 4. `{parent.type}` – the fully qualified name of the field declaring type.
// 5. `{regex.pattern}` – the specified regex pattern.
// 6. `{regex.modifiers}` – the specified modifiers, if any. For example, `[dot_all, unicode]`.
// 1. `${field.name}` – the field name.
// 2. `${field.value}` - the field value.
// 3. `${field.type}` – the fully qualified name of the field type.
// 4. `${parent.type}` – the fully qualified name of the field declaring type.
// 5. `${regex.pattern}` – the specified regex pattern.
// 6. `${regex.modifiers}` – the specified modifiers, if any. For example, `[dot_all, unicode]`.
//
// The placeholders will be replaced at runtime when the error is constructed.
//
Expand Down Expand Up @@ -876,7 +876,7 @@ message PatternOption {
message IfInvalidOption {

// The default error message.
option (default_message) = "The field `{parent.type}.{field.name}` of the type `{field.type}` is invalid. The field value: `{field.value}`.";
option (default_message) = "The field `${parent.type}.${field.name}` of the type `${field.type}` is invalid. The field value: `${field.value}`.";

// A user-defined validation error format message.
//
Expand All @@ -888,18 +888,18 @@ message IfInvalidOption {
//
// The specified message may include the following placeholders:
//
// 1. `{field.name}` – the field name.
// 2. `{field.value}` - the field value.
// 3. `{field.type}` – the fully qualified name of the field type.
// 4. `{parent.type}` – the fully qualified name of the field declaring type.
// 1. `${field.name}` – the field name.
// 2. `${field.value}` - the field value.
// 3. `${field.type}` – the fully qualified name of the field type.
// 4. `${parent.type}` – the fully qualified name of the field declaring type.
//
// The placeholders will be replaced at runtime when the error is constructed.
//
// Example: Using the `(if_invalid)` option.
//
// message Transaction {
// TransactionDetails details = 1 [(validate) = true,
// (if_invalid).error_msg = "The `{field.name}` field is invalid."];
// (if_invalid).error_msg = "The `${field.name}` field is invalid."];
// }
//
string error_msg = 2;
Expand Down Expand Up @@ -929,7 +929,7 @@ message IfInvalidOption {
message GoesOption {

// The default error message.
option (default_message) = "The field `{goes.companion}` must also be set when `{field.name}` is set in `{parent.type}`.";
option (default_message) = "The field `${goes.companion}` must also be set when `${field.name}` is set in `${parent.type}`.";

// The name of the companion field whose presence is required for this field to be valid.
string with = 1;
Expand All @@ -941,11 +941,11 @@ message GoesOption {
//
// The specified message may include the following placeholders:
//
// 1. `{field.name}` – the field name.
// 2. `{field.value}` – the field value.
// 3. `{field.type}` – the fully qualified name of the field type.
// 4. `{parent.type}` – the fully qualified name of the field declaring type.
// 5. `{goes.companion}` – the name of the companion specified in `with`.
// 1. `${field.name}` – the field name.
// 2. `${field.value}` – the field value.
// 3. `${field.type}` – the fully qualified name of the field type.
// 4. `${parent.type}` – the fully qualified name of the field declaring type.
// 5. `${goes.companion}` – the name of the companion specified in `with`.
//
// The placeholders will be replaced at runtime when the error is constructed.
//
Expand Down Expand Up @@ -1121,17 +1121,17 @@ message CompareByOption {
message IfSetAgainOption {

// The default error message.
option (default_message) = "The field `{parent.type}.{field.name}` of the type `{field.type}` already has the value `{field.value}` and cannot be reassigned to `{field.proposed_value}`.";
option (default_message) = "The field `${parent.type}.${field.name}` of the type `${field.type}` already has the value `${field.value}` and cannot be reassigned to `${field.proposed_value}`.";

// A user-defined error message.
//
// The specified message may include the following placeholders:
//
// 1. `{field.name}` – the field name.
// 2. `{field.type}` – the fully qualified name of the field type.
// 3. `{field.value}` – the current field value.
// 4. `{field.proposed_value}` – the value, which was attempted to be set.
// 5. `{parent.type}` – the fully qualified name of the field declaring type.
// 1. `${field.name}` – the field name.
// 2. `${field.type}` – the fully qualified name of the field type.
// 3. `${field.value}` – the current field value.
// 4. `${field.proposed_value}` – the value, which was attempted to be set.
// 5. `${parent.type}` – the fully qualified name of the field declaring type.
//
// The placeholders will be replaced at runtime when the error is constructed.
//
Expand All @@ -1152,25 +1152,25 @@ message IfSetAgainOption {
message IfHasDuplicatesOption {

// The default error message.
option (default_message) = "The field `{parent.type}.{field.name}` of the type `{field.type}` must not contain duplicates. The duplicates found: `{field.duplicates}`.";
option (default_message) = "The field `${parent.type}.${field.name}` of the type `${field.type}` must not contain duplicates. The duplicates found: `${field.duplicates}`.";

// A user-defined error message.
//
// The specified message may include the following placeholders:
//
// 1. `{field.name}` – the field name.
// 2. `{field.type}` – the fully qualified name of the field type.
// 3. `{field.value}` – the field value (the whole collection).
// 4. `{field.duplicates}` – the duplicates found (elements that occur more than once).
// 5. `{parent.type}` – the fully qualified name of the field declaring type.
// 1. `${field.name}` – the field name.
// 2. `${field.type}` – the fully qualified name of the field type.
// 3. `${field.value}` – the field value (the whole collection).
// 4. `${field.duplicates}` – the duplicates found (elements that occur more than once).
// 5. `${parent.type}` – the fully qualified name of the field declaring type.
//
// The placeholders will be replaced at runtime when the error is constructed.
//
// Example: Using the `(distinct)` option.
//
// message Blizzard {
// repeated Snowflake = 1 [(distinct) = true,
// (if_has_duplicates).error_msg = "Every snowflake must be unique! The duplicates found: `{field.duplicates}`."];
// (if_has_duplicates).error_msg = "Every snowflake must be unique! The duplicates found: `${field.duplicates}`."];
// }
//
string error_msg = 1;
Expand All @@ -1184,7 +1184,7 @@ message IfHasDuplicatesOption {
message RangeOption {

// The default error message.
option (default_message) = "The field `{parent.type}.{field.name}` must be within the following range: `{range.value}`.";
option (default_message) = "The field `${parent.type}.${field.name}` must be within the following range: `${range.value}`.";

// The string representation of the range.
//
Expand Down Expand Up @@ -1212,11 +1212,11 @@ message RangeOption {
//
// The specified message may include the following placeholders:
//
// 1. `{field.name}` – the field name.
// 2. `{field.value}` - the field value.
// 3. `{field.type}` – the fully qualified name of the field type.
// 4. `{parent.type}` – the fully qualified name of the field declaring type.
// 5. `{range.value}` – the specified range.
// 1. `${field.name}` – the field name.
// 2. `${field.value}` - the field value.
// 3. `${field.type}` – the fully qualified name of the field type.
// 4. `${parent.type}` – the fully qualified name of the field declaring type.
// 5. `${range.value}` – the specified range.
//
// The placeholders will be replaced at runtime when the error is constructed.
//
Expand Down
2 changes: 1 addition & 1 deletion version.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

val versionToPublish: String by extra("2.0.0-SNAPSHOT.233")
val versionToPublish: String by extra("2.0.0-SNAPSHOT.234")

0 comments on commit f4e6ddc

Please sign in to comment.