Skip to content

Commit aafe2e1

Browse files
Merge pull request #847 from SpineEventEngine/use-field-paths
Talk about `field.path` in API of validation options
2 parents f4e6ddc + 0981aec commit aafe2e1

File tree

4 files changed

+32
-69
lines changed

4 files changed

+32
-69
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.234`
3+
# Dependencies of `io.spine:spine-base:2.0.0-SNAPSHOT.235`
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 **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).
848+
This report was generated on **Tue Jan 07 13:42:22 CET 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).

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.234</version>
13+
<version>2.0.0-SNAPSHOT.235</version>
1414

1515
<inceptionYear>2015</inceptionYear>
1616

src/main/proto/spine/options.proto

+28-65
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ extend google.protobuf.FieldOptions {
148148
//
149149
bool validate = 73821;
150150

151-
// See `IfInvalidOption`.
152-
IfInvalidOption if_invalid = 73822;
151+
// Reserved 73822 for deleted `(if_invalid)` option.
153152

154153
// See `GoesOption`.
155154
GoesOption goes = 73823;
@@ -361,7 +360,7 @@ extend google.protobuf.MessageOptions {
361360
// ```
362361
// message GoesOption {
363362
// // The default error message.
364-
// option (default_message) = "The field `${goes.companion}` must also be set when `${field.name}` is set.";
363+
// option (default_message) = "The field `${goes.companion}` must also be set when `${field.path}` is set.";
365364
// }
366365
// ```
367366
//
@@ -372,7 +371,7 @@ extend google.protobuf.MessageOptions {
372371

373372
// The constraint to require at least one of the fields or a combination of fields.
374373
//
375-
// Unlike the `required` field constraint which always require corresponding field,
374+
// Unlike the `required` field constraint which always requires corresponding field,
376375
// this message option allows to require alternative fields or a combination of them as
377376
// an alternative. Field names and `oneof` group names are acceptable.
378377
//
@@ -650,7 +649,7 @@ extend google.protobuf.ServiceOptions {
650649
message IfMissingOption {
651650

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

655654
// A user-defined validation error format message.
656655
//
@@ -662,17 +661,17 @@ message IfMissingOption {
662661
//
663662
// The specified message may include the following placeholders:
664663
//
665-
// 1. `${field.name}` – the field name.
664+
// 1. `${field.path}` – the field path.
666665
// 2. `${field.type}` – the fully qualified name of the field type.
667-
// 3. `${parent.type}` – the fully qualified name of the field declaring type.
666+
// 3. `${parent.type}` – the fully qualified name of the validated message.
668667
//
669668
// The placeholders will be replaced at runtime when the error is constructed.
670669
//
671670
// Example: Using the `(if_missing)` option.
672671
//
673672
// message Student {
674673
// Name name = 1 [(required) = true,
675-
// (if_missing).error_msg = "The `${field.name}` field is mandatory for `${parent.type}`."];
674+
// (if_missing).error_msg = "The `${field.path}` field is mandatory for `${parent.type}`."];
676675
// }
677676
//
678677
string error_msg = 2;
@@ -696,7 +695,7 @@ message IfMissingOption {
696695
message MinOption {
697696

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

701700
// The string representation of the minimum field value.
702701
string value = 1;
@@ -715,9 +714,9 @@ message MinOption {
715714
// The specified message may include the following placeholders:
716715
//
717716
// 1. `${field.value}` - the field value.
718-
// 2. `${field.name}` – the field name.
717+
// 2. `${field.path}` – the field path.
719718
// 3. `${field.type}` – the fully qualified name of the field type.
720-
// 4. `${parent.type}` – the fully qualified name of the field declaring type.
719+
// 4. `${parent.type}` – the fully qualified name of the validated message.
721720
// 5. `${min.value}` – the specified minimum `value`.
722721
// 6. `${min.operator}` – if `exclusive` is set to `true`, this placeholder equals to ">".
723722
// Otherwise, ">=".
@@ -742,7 +741,7 @@ message MinOption {
742741
message MaxOption {
743742

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

747746
// The string representation of the maximum field value.
748747
string value = 1;
@@ -760,10 +759,10 @@ message MaxOption {
760759
//
761760
// The specified message may include the following placeholders:
762761
//
763-
// 1. `${field.name}` – the field name.
762+
// 1. `${field.path}` – the field path.
764763
// 2. `${field.value}` - the field value.
765764
// 3. `${field.type}` – the fully qualified name of the field type.
766-
// 4. `${parent.type}` – the fully qualified name of the field declaring type.
765+
// 4. `${parent.type}` – the fully qualified name of the validated message.
767766
// 5. `${max.value}` – the specified maximum `value`.
768767
// 6. `${max.operator}` – if `exclusive` is set to `true`, this placeholder equals to "<".
769768
// Otherwise, "<=".
@@ -788,7 +787,7 @@ message MaxOption {
788787
message PatternOption {
789788

790789
// 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}`.";
790+
option (default_message) = "The `${parent.type}.${field.path}` field must match the regular expression `${regex.pattern}` (modifiers: `${regex.modifiers}`). The passed value: `${field.value}`.";
792791

793792
// The regular expression to match.
794793
string regex = 1;
@@ -806,10 +805,10 @@ message PatternOption {
806805
//
807806
// The specified message may include the following placeholders:
808807
//
809-
// 1. `${field.name}` – the field name.
808+
// 1. `${field.path}` – the field path.
810809
// 2. `${field.value}` - the field value.
811810
// 3. `${field.type}` – the fully qualified name of the field type.
812-
// 4. `${parent.type}` – the fully qualified name of the field declaring type.
811+
// 4. `${parent.type}` – the fully qualified name of the validated message.
813812
// 5. `${regex.pattern}` – the specified regex pattern.
814813
// 6. `${regex.modifiers}` – the specified modifiers, if any. For example, `[dot_all, unicode]`.
815814
//
@@ -869,42 +868,6 @@ message PatternOption {
869868
}
870869
}
871870

872-
// Specifies the message to show if a validated field happens to be invalid.
873-
//
874-
// It is applicable only to fields marked with `(validate)`.
875-
//
876-
message IfInvalidOption {
877-
878-
// 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}`.";
880-
881-
// A user-defined validation error format message.
882-
//
883-
// Use `error_msg` instead.
884-
//
885-
string msg_format = 1 [deprecated = true];
886-
887-
// A user-defined error message.
888-
//
889-
// The specified message may include the following placeholders:
890-
//
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.
895-
//
896-
// The placeholders will be replaced at runtime when the error is constructed.
897-
//
898-
// Example: Using the `(if_invalid)` option.
899-
//
900-
// message Transaction {
901-
// TransactionDetails details = 1 [(validate) = true,
902-
// (if_invalid).error_msg = "The `${field.name}` field is invalid."];
903-
// }
904-
//
905-
string error_msg = 2;
906-
}
907-
908871
// Specifies that another field must be present if the option's target field is present.
909872
//
910873
// Unlike the `required_field` that handles combination of required fields, this option is useful
@@ -929,7 +892,7 @@ message IfInvalidOption {
929892
message GoesOption {
930893

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

934897
// The name of the companion field whose presence is required for this field to be valid.
935898
string with = 1;
@@ -941,10 +904,10 @@ message GoesOption {
941904
//
942905
// The specified message may include the following placeholders:
943906
//
944-
// 1. `${field.name}` – the field name.
907+
// 1. `${field.path}` – the field path.
945908
// 2. `${field.value}` – the field value.
946909
// 3. `${field.type}` – the fully qualified name of the field type.
947-
// 4. `${parent.type}` – the fully qualified name of the field declaring type.
910+
// 4. `${parent.type}` – the fully qualified name of the validated message.
948911
// 5. `${goes.companion}` – the name of the companion specified in `with`.
949912
//
950913
// The placeholders will be replaced at runtime when the error is constructed.
@@ -1121,17 +1084,17 @@ message CompareByOption {
11211084
message IfSetAgainOption {
11221085

11231086
// 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}`.";
1087+
option (default_message) = "The field `${parent.type}.${field.path}` of the type `${field.type}` already has the value `${field.value}` and cannot be reassigned to `${field.proposed_value}`.";
11251088

11261089
// A user-defined error message.
11271090
//
11281091
// The specified message may include the following placeholders:
11291092
//
1130-
// 1. `${field.name}` – the field name.
1093+
// 1. `${field.path}` – the field path.
11311094
// 2. `${field.type}` – the fully qualified name of the field type.
11321095
// 3. `${field.value}` – the current field value.
11331096
// 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.
1097+
// 5. `${parent.type}` – the fully qualified name of the validated message.
11351098
//
11361099
// The placeholders will be replaced at runtime when the error is constructed.
11371100
//
@@ -1152,17 +1115,17 @@ message IfSetAgainOption {
11521115
message IfHasDuplicatesOption {
11531116

11541117
// 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}`.";
1118+
option (default_message) = "The field `${parent.type}.${field.path}` of the type `${field.type}` must not contain duplicates. The duplicates found: `${field.duplicates}`.";
11561119

11571120
// A user-defined error message.
11581121
//
11591122
// The specified message may include the following placeholders:
11601123
//
1161-
// 1. `${field.name}` – the field name.
1124+
// 1. `${field.path}` – the field path.
11621125
// 2. `${field.type}` – the fully qualified name of the field type.
11631126
// 3. `${field.value}` – the field value (the whole collection).
11641127
// 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.
1128+
// 5. `${parent.type}` – the fully qualified name of the validated message.
11661129
//
11671130
// The placeholders will be replaced at runtime when the error is constructed.
11681131
//
@@ -1184,7 +1147,7 @@ message IfHasDuplicatesOption {
11841147
message RangeOption {
11851148

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

11891152
// The string representation of the range.
11901153
//
@@ -1212,10 +1175,10 @@ message RangeOption {
12121175
//
12131176
// The specified message may include the following placeholders:
12141177
//
1215-
// 1. `${field.name}` – the field name.
1178+
// 1. `${field.path}` – the field path.
12161179
// 2. `${field.value}` - the field value.
12171180
// 3. `${field.type}` – the fully qualified name of the field type.
1218-
// 4. `${parent.type}` – the fully qualified name of the field declaring type.
1181+
// 4. `${parent.type}` – the fully qualified name of the validated message.
12191182
// 5. `${range.value}` – the specified range.
12201183
//
12211184
// The placeholders will be replaced at runtime when the error is constructed.

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.234")
27+
val versionToPublish: String by extra("2.0.0-SNAPSHOT.235")

0 commit comments

Comments
 (0)