Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore and deprecate if_invalid option #848

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.235`
# Dependencies of `io.spine:spine-base:2.0.0-SNAPSHOT.236`

## 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 **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).
This report was generated on **Wed Jan 08 16:19:17 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).
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.235</version>
<version>2.0.0-SNAPSHOT.236</version>

<inceptionYear>2015</inceptionYear>

Expand Down
43 changes: 42 additions & 1 deletion src/main/proto/spine/options.proto
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ extend google.protobuf.FieldOptions {
//
bool validate = 73821;

// Reserved 73822 for deleted `(if_invalid)` option.
// See `IfInvalidOption`.
IfInvalidOption if_invalid = 73822 [deprecated = true];

// See `GoesOption`.
GoesOption goes = 73823;
Expand Down Expand Up @@ -868,6 +869,46 @@ message PatternOption {
}
}

// Specifies the message to show if a validated field happens to be invalid.
//
// It is applicable only to fields marked with `(validate)`.
//
message IfInvalidOption {

// Do not specify error message for `(validate)`, it is no longer used by
// the validation library.
option deprecated = true;

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

// A user-defined validation error format message.
//
// Use `error_msg` instead.
//
string msg_format = 1 [deprecated = true];

// A user-defined error message.
//
// The specified message may include the following placeholders:
//
// 1. `${field.path}` – the field path.
// 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.path}` field is invalid."];
// }
//
string error_msg = 2;
}

// 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
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.235")
val versionToPublish: String by extra("2.0.0-SNAPSHOT.236")
Loading