Skip to content

Commit e32c436

Browse files
Specify support for message patterns
1 parent e8b652b commit e32c436

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

src/main/proto/spine/options.proto

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ extend google.protobuf.FieldOptions {
158158
//
159159
// Once set, the `id` field cannot be changed.
160160
//
161+
// Use `(if_set_again).error_msg` option to specify a custom error message that will be shown
162+
// on attempt to re-assign the field value.
163+
//
161164
bool set_once = 73824;
162165

163166
// The option to mark a `repeated` field as a collection of unique elements.
@@ -267,7 +270,10 @@ extend google.protobuf.FieldOptions {
267270
//
268271
bool column = 73854;
269272

270-
// See `IfSetAgainOption`.
273+
// Defines the error message used if a `set_once` field is set again.
274+
//
275+
// Applies only to the fields marked as `set_once`.
276+
//
271277
IfSetAgainOption if_set_again = 73855;
272278

273279
// Reserved 73856 to 73890 for future options.
@@ -1011,18 +1017,26 @@ message CompareByOption {
10111017
//
10121018
// Applies only to the fields marked as `set_once`.
10131019
//
1014-
// Example: Using the `(set_once)` option.
1015-
//
1016-
// message User {
1017-
// UserId id = 1 [(set_once) = true,
1018-
// (if_set_again).error_msg = "The student ID cannot be re-assigned."];
1019-
// }
1020-
//
10211020
message IfSetAgainOption {
10221021

1023-
// The default error message for the field.
1024-
option (default_message) = "The field value cannot be re-assigned.";
1022+
// The default error message used when the field is re-assigned.
1023+
option (default_message) = "The field `{fieldName}` cannot be re-assigned.";
10251024

1026-
// A user-defined error message.
1025+
// A user-defined error message pattern.
1026+
//
1027+
// The specified message may include the following tokens:
1028+
// 1. `{fieldName}` — the field name.
1029+
// 2. `{currentValue}` — the field's current value.
1030+
// 3. `{newValue} — the field's new value.
1031+
//
1032+
// The tokens will be replaced at runtime when the error is constructed.
1033+
//
1034+
// Example: Using the `(set_once)` option.
1035+
//
1036+
// message User {
1037+
// UserId id = 1 [(set_once) = true,
1038+
// (if_set_again).error_msg = "The student ID cannot be re-assigned. The suggested value: `{newValue}`."];
1039+
// }
1040+
//
10271041
string error_msg = 1;
10281042
}

0 commit comments

Comments
 (0)