Skip to content

Commit

Permalink
Update specs to (goes) option
Browse files Browse the repository at this point in the history
  • Loading branch information
yevhenii-nadtochii committed Dec 9, 2024
1 parent 0be904f commit b61353f
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/main/proto/spine/options.proto
Original file line number Diff line number Diff line change
Expand Up @@ -857,11 +857,18 @@ message IfInvalidOption {
string error_msg = 2;
}

// Specifies that a message field can be present only if another field is present.
// Specifies that another field must be present if the option's target field is present.
//
// Unlike the `required_field` that handles combination of required fields, this option is useful
// when it is needed to say that an optional field makes sense only when another optional field is
// present.
// when it is needed to say that an optional field makes sense only when another optional field
// is present.
//
// This option can be applied to the same field types as `(required)`, including both the
// target field and its companion. Supported field types are:
//
// - Messages and enums.
// - Repeated fields and maps.
// - `string` and `bytes`.
//
// Example: Requiring mutual presence of optional fields.
//
Expand All @@ -873,23 +880,23 @@ message IfInvalidOption {
//
message GoesOption {

// The default error message format string.
//
// The first parameter is the name of the field for which we specify the option.
// The second parameter is the name of the field set in the "with" value.
//
// The default error message used when the companion field specified in `with` is not present
// alongside the target field.
option (default_message) = "The field `%s` can only be set when the field `%s` is defined.";

// A name of the field required for presence of the field for which we set the option.
// The name of the companion field whose presence is required for this field to be valid.
string with = 1;

// A user-defined validation error format message.
string msg_format = 2 [deprecated = true];

// A user-defined validation error format message.
// A user-defined error message.
//
// May include the token `{value}` for the actual value of the field. The token will be replaced
// at runtime when the error is constructed.
// The specified message may include the following tokens:
// 1. `{fieldName}` – the name of the field to which this option is applied.
// 2. `{companionName}` – the name of the companion field specified in `with`.
//
// The tokens will be replaced at runtime when the error is constructed.
//
string error_msg = 3;
}
Expand Down

0 comments on commit b61353f

Please sign in to comment.