Skip to content

Commit f4e6ddc

Browse files
Merge pull request #846 from SpineEventEngine/use-kotlin-templates
Use Kotlin-like placeholder in error message templates
2 parents 89e016b + 4ca90c8 commit f4e6ddc

File tree

4 files changed

+65
-65
lines changed

4 files changed

+65
-65
lines changed

dependencies.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

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

55
## Runtime
66
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
@@ -845,4 +845,4 @@
845845

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

848-
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).
848+
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).

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ all modules and does not describe the project structure per-subproject.
1010
-->
1111
<groupId>io.spine</groupId>
1212
<artifactId>base</artifactId>
13-
<version>2.0.0-SNAPSHOT.233</version>
13+
<version>2.0.0-SNAPSHOT.234</version>
1414

1515
<inceptionYear>2015</inceptionYear>
1616

src/main/proto/spine/options.proto

+61-61
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ extend google.protobuf.MessageOptions {
361361
// ```
362362
// message GoesOption {
363363
// // The default error message.
364-
// option (default_message) = "The field `{goes.companion}` must also be set when `{field.name}` is set.";
364+
// option (default_message) = "The field `${goes.companion}` must also be set when `${field.name}` is set.";
365365
// }
366366
// ```
367367
//
@@ -650,7 +650,7 @@ extend google.protobuf.ServiceOptions {
650650
message IfMissingOption {
651651

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

655655
// A user-defined validation error format message.
656656
//
@@ -662,17 +662,17 @@ message IfMissingOption {
662662
//
663663
// The specified message may include the following placeholders:
664664
//
665-
// 1. `{field.name}` – the field name.
666-
// 2. `{field.type}` – the fully qualified name of the field type.
667-
// 3. `{parent.type}` – the fully qualified name of the field declaring type.
665+
// 1. `${field.name}` – the field name.
666+
// 2. `${field.type}` – the fully qualified name of the field type.
667+
// 3. `${parent.type}` – the fully qualified name of the field declaring type.
668668
//
669669
// The placeholders will be replaced at runtime when the error is constructed.
670670
//
671671
// Example: Using the `(if_missing)` option.
672672
//
673673
// message Student {
674674
// Name name = 1 [(required) = true,
675-
// (if_missing).error_msg = "The `{field.name}` field is mandatory for `{parent.type}`."];
675+
// (if_missing).error_msg = "The `${field.name}` field is mandatory for `${parent.type}`."];
676676
// }
677677
//
678678
string error_msg = 2;
@@ -689,14 +689,14 @@ message IfMissingOption {
689689
// double value = 1 [(min) = {
690690
// value: "0.0",
691691
// exclusive: true,
692-
// error_msg: "The temperature cannot reach `{min.value}K`, but provided `{field.value}`."
692+
// error_msg: "The temperature cannot reach `${min.value}K`, but provided `${field.value}`."
693693
// }];
694694
// }
695695
//
696696
message MinOption {
697697

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

701701
// The string representation of the minimum field value.
702702
string value = 1;
@@ -714,12 +714,12 @@ message MinOption {
714714
//
715715
// The specified message may include the following placeholders:
716716
//
717-
// 1. `{field.value}` - the field value.
718-
// 2. `{field.name}` – the field name.
719-
// 3. `{field.type}` – the fully qualified name of the field type.
720-
// 4. `{parent.type}` – the fully qualified name of the field declaring type.
721-
// 5. `{min.value}` – the specified minimum `value`.
722-
// 6. `{min.operator}` – if `exclusive` is set to `true`, this placeholder equals to ">".
717+
// 1. `${field.value}` - the field value.
718+
// 2. `${field.name}` – the field name.
719+
// 3. `${field.type}` – the fully qualified name of the field type.
720+
// 4. `${parent.type}` – the fully qualified name of the field declaring type.
721+
// 5. `${min.value}` – the specified minimum `value`.
722+
// 6. `${min.operator}` – if `exclusive` is set to `true`, this placeholder equals to ">".
723723
// Otherwise, ">=".
724724
//
725725
// The placeholders will be replaced at runtime when the error is constructed.
@@ -736,13 +736,13 @@ message MinOption {
736736
//
737737
// message TowerCrane {
738738
// double load = 1 [(max).value = "4.2",
739-
// (max).error_msg = "The crane load in `{parent.type}` can not exceed `{max.value}` tons, but provided `{field.value}`."];
739+
// (max).error_msg = "The crane load in `${parent.type}` can not exceed `${max.value}` tons, but provided `${field.value}`."];
740740
// }
741741
//
742742
message MaxOption {
743743

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

747747
// The string representation of the maximum field value.
748748
string value = 1;
@@ -760,12 +760,12 @@ message MaxOption {
760760
//
761761
// The specified message may include the following placeholders:
762762
//
763-
// 1. `{field.name}` – the field name.
764-
// 2. `{field.value}` - the field value.
765-
// 3. `{field.type}` – the fully qualified name of the field type.
766-
// 4. `{parent.type}` – the fully qualified name of the field declaring type.
767-
// 5. `{max.value}` – the specified maximum `value`.
768-
// 6. `{max.operator}` – if `exclusive` is set to `true`, this placeholder equals to "<".
763+
// 1. `${field.name}` – the field name.
764+
// 2. `${field.value}` - the field value.
765+
// 3. `${field.type}` – the fully qualified name of the field type.
766+
// 4. `${parent.type}` – the fully qualified name of the field declaring type.
767+
// 5. `${max.value}` – the specified maximum `value`.
768+
// 6. `${max.operator}` – if `exclusive` is set to `true`, this placeholder equals to "<".
769769
// Otherwise, "<=".
770770
//
771771
// The placeholders will be replaced at runtime when the error is constructed.
@@ -782,13 +782,13 @@ message MaxOption {
782782
//
783783
// message CreateAccount {
784784
// string id = 1 [(pattern).regex = "^[A-Za-z0-9+]+$",
785-
// (pattern).error_msg = "ID must be alphanumerical in `{parent.type}`. Provided: `{field.value}`."];
785+
// (pattern).error_msg = "ID must be alphanumerical in `${parent.type}`. Provided: `${field.value}`."];
786786
// }
787787
//
788788
message PatternOption {
789789

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

793793
// The regular expression to match.
794794
string regex = 1;
@@ -806,12 +806,12 @@ message PatternOption {
806806
//
807807
// The specified message may include the following placeholders:
808808
//
809-
// 1. `{field.name}` – the field name.
810-
// 2. `{field.value}` - the field value.
811-
// 3. `{field.type}` – the fully qualified name of the field type.
812-
// 4. `{parent.type}` – the fully qualified name of the field declaring type.
813-
// 5. `{regex.pattern}` – the specified regex pattern.
814-
// 6. `{regex.modifiers}` – the specified modifiers, if any. For example, `[dot_all, unicode]`.
809+
// 1. `${field.name}` – the field name.
810+
// 2. `${field.value}` - the field value.
811+
// 3. `${field.type}` – the fully qualified name of the field type.
812+
// 4. `${parent.type}` – the fully qualified name of the field declaring type.
813+
// 5. `${regex.pattern}` – the specified regex pattern.
814+
// 6. `${regex.modifiers}` – the specified modifiers, if any. For example, `[dot_all, unicode]`.
815815
//
816816
// The placeholders will be replaced at runtime when the error is constructed.
817817
//
@@ -876,7 +876,7 @@ message PatternOption {
876876
message IfInvalidOption {
877877

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

881881
// A user-defined validation error format message.
882882
//
@@ -888,18 +888,18 @@ message IfInvalidOption {
888888
//
889889
// The specified message may include the following placeholders:
890890
//
891-
// 1. `{field.name}` – the field name.
892-
// 2. `{field.value}` - the field value.
893-
// 3. `{field.type}` – the fully qualified name of the field type.
894-
// 4. `{parent.type}` – the fully qualified name of the field declaring type.
891+
// 1. `${field.name}` – the field name.
892+
// 2. `${field.value}` - the field value.
893+
// 3. `${field.type}` – the fully qualified name of the field type.
894+
// 4. `${parent.type}` – the fully qualified name of the field declaring type.
895895
//
896896
// The placeholders will be replaced at runtime when the error is constructed.
897897
//
898898
// Example: Using the `(if_invalid)` option.
899899
//
900900
// message Transaction {
901901
// TransactionDetails details = 1 [(validate) = true,
902-
// (if_invalid).error_msg = "The `{field.name}` field is invalid."];
902+
// (if_invalid).error_msg = "The `${field.name}` field is invalid."];
903903
// }
904904
//
905905
string error_msg = 2;
@@ -929,7 +929,7 @@ message IfInvalidOption {
929929
message GoesOption {
930930

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

934934
// The name of the companion field whose presence is required for this field to be valid.
935935
string with = 1;
@@ -941,11 +941,11 @@ message GoesOption {
941941
//
942942
// The specified message may include the following placeholders:
943943
//
944-
// 1. `{field.name}` – the field name.
945-
// 2. `{field.value}` – the field value.
946-
// 3. `{field.type}` – the fully qualified name of the field type.
947-
// 4. `{parent.type}` – the fully qualified name of the field declaring type.
948-
// 5. `{goes.companion}` – the name of the companion specified in `with`.
944+
// 1. `${field.name}` – the field name.
945+
// 2. `${field.value}` – the field value.
946+
// 3. `${field.type}` – the fully qualified name of the field type.
947+
// 4. `${parent.type}` – the fully qualified name of the field declaring type.
948+
// 5. `${goes.companion}` – the name of the companion specified in `with`.
949949
//
950950
// The placeholders will be replaced at runtime when the error is constructed.
951951
//
@@ -1121,17 +1121,17 @@ message CompareByOption {
11211121
message IfSetAgainOption {
11221122

11231123
// The default error message.
1124-
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}`.";
1124+
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}`.";
11251125

11261126
// A user-defined error message.
11271127
//
11281128
// The specified message may include the following placeholders:
11291129
//
1130-
// 1. `{field.name}` – the field name.
1131-
// 2. `{field.type}` – the fully qualified name of the field type.
1132-
// 3. `{field.value}` – the current field value.
1133-
// 4. `{field.proposed_value}` – the value, which was attempted to be set.
1134-
// 5. `{parent.type}` – the fully qualified name of the field declaring type.
1130+
// 1. `${field.name}` – the field name.
1131+
// 2. `${field.type}` – the fully qualified name of the field type.
1132+
// 3. `${field.value}` – the current field value.
1133+
// 4. `${field.proposed_value}` – the value, which was attempted to be set.
1134+
// 5. `${parent.type}` – the fully qualified name of the field declaring type.
11351135
//
11361136
// The placeholders will be replaced at runtime when the error is constructed.
11371137
//
@@ -1152,25 +1152,25 @@ message IfSetAgainOption {
11521152
message IfHasDuplicatesOption {
11531153

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

11571157
// A user-defined error message.
11581158
//
11591159
// The specified message may include the following placeholders:
11601160
//
1161-
// 1. `{field.name}` – the field name.
1162-
// 2. `{field.type}` – the fully qualified name of the field type.
1163-
// 3. `{field.value}` – the field value (the whole collection).
1164-
// 4. `{field.duplicates}` – the duplicates found (elements that occur more than once).
1165-
// 5. `{parent.type}` – the fully qualified name of the field declaring type.
1161+
// 1. `${field.name}` – the field name.
1162+
// 2. `${field.type}` – the fully qualified name of the field type.
1163+
// 3. `${field.value}` – the field value (the whole collection).
1164+
// 4. `${field.duplicates}` – the duplicates found (elements that occur more than once).
1165+
// 5. `${parent.type}` – the fully qualified name of the field declaring type.
11661166
//
11671167
// The placeholders will be replaced at runtime when the error is constructed.
11681168
//
11691169
// Example: Using the `(distinct)` option.
11701170
//
11711171
// message Blizzard {
11721172
// repeated Snowflake = 1 [(distinct) = true,
1173-
// (if_has_duplicates).error_msg = "Every snowflake must be unique! The duplicates found: `{field.duplicates}`."];
1173+
// (if_has_duplicates).error_msg = "Every snowflake must be unique! The duplicates found: `${field.duplicates}`."];
11741174
// }
11751175
//
11761176
string error_msg = 1;
@@ -1184,7 +1184,7 @@ message IfHasDuplicatesOption {
11841184
message RangeOption {
11851185

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

11891189
// The string representation of the range.
11901190
//
@@ -1212,11 +1212,11 @@ message RangeOption {
12121212
//
12131213
// The specified message may include the following placeholders:
12141214
//
1215-
// 1. `{field.name}` – the field name.
1216-
// 2. `{field.value}` - the field value.
1217-
// 3. `{field.type}` – the fully qualified name of the field type.
1218-
// 4. `{parent.type}` – the fully qualified name of the field declaring type.
1219-
// 5. `{range.value}` – the specified range.
1215+
// 1. `${field.name}` – the field name.
1216+
// 2. `${field.value}` - the field value.
1217+
// 3. `${field.type}` – the fully qualified name of the field type.
1218+
// 4. `${parent.type}` – the fully qualified name of the field declaring type.
1219+
// 5. `${range.value}` – the specified range.
12201220
//
12211221
// The placeholders will be replaced at runtime when the error is constructed.
12221222
//

version.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2525
*/
2626

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

0 commit comments

Comments
 (0)