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

Support field references in min_value and max_value #137

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ object ProtoData {
* The version of ProtoData dependencies.
*/
val version: String
private const val fallbackVersion = "0.61.4"
private const val fallbackVersion = "0.61.6"

/**
* The distinct version of ProtoData used by other build tools.
Expand All @@ -82,7 +82,7 @@ object ProtoData {
* transitional dependencies, this is the version used to build the project itself.
*/
val dogfoodingVersion: String
private const val fallbackDfVersion = "0.61.4"
private const val fallbackDfVersion = "0.61.6"

/**
* The artifact for the ProtoData Gradle plugin.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ object Spine {
* @see [Spine.CoreJava.server]
* @see <a href="https://github.com/SpineEventEngine/core-java">core-java</a>
*/
const val core = "2.0.0-SNAPSHOT.176"
const val core = "2.0.0-SNAPSHOT.177"

/**
* The version of [Spine.modelCompiler].
Expand Down
34 changes: 17 additions & 17 deletions dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@

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

This report was generated on **Tue Oct 08 17:36:52 WEST 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).
This report was generated on **Thu Oct 10 18:03:16 WEST 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).



Expand Down Expand Up @@ -1673,7 +1673,7 @@ This report was generated on **Tue Oct 08 17:36:52 WEST 2024** using [Gradle-Lic

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

This report was generated on **Tue Oct 08 17:36:52 WEST 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).
This report was generated on **Thu Oct 10 18:03:16 WEST 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).



Expand Down Expand Up @@ -2364,7 +2364,7 @@ This report was generated on **Tue Oct 08 17:36:52 WEST 2024** using [Gradle-Lic

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

This report was generated on **Tue Oct 08 17:36:52 WEST 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).
This report was generated on **Thu Oct 10 18:03:16 WEST 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).



Expand Down Expand Up @@ -2979,7 +2979,7 @@ This report was generated on **Tue Oct 08 17:36:52 WEST 2024** using [Gradle-Lic

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

This report was generated on **Tue Oct 08 17:36:52 WEST 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).
This report was generated on **Thu Oct 10 18:03:16 WEST 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).



Expand Down Expand Up @@ -3904,7 +3904,7 @@ This report was generated on **Tue Oct 08 17:36:52 WEST 2024** using [Gradle-Lic

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

This report was generated on **Tue Oct 08 17:36:53 WEST 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).
This report was generated on **Thu Oct 10 18:03:17 WEST 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).



Expand Down Expand Up @@ -4764,7 +4764,7 @@ This report was generated on **Tue Oct 08 17:36:53 WEST 2024** using [Gradle-Lic

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

This report was generated on **Tue Oct 08 17:36:53 WEST 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).
This report was generated on **Thu Oct 10 18:03:17 WEST 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).



Expand Down Expand Up @@ -5622,7 +5622,7 @@ This report was generated on **Tue Oct 08 17:36:53 WEST 2024** using [Gradle-Lic

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

This report was generated on **Tue Oct 08 17:36:53 WEST 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).
This report was generated on **Thu Oct 10 18:03:17 WEST 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).



Expand Down Expand Up @@ -6495,7 +6495,7 @@ This report was generated on **Tue Oct 08 17:36:53 WEST 2024** using [Gradle-Lic

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

This report was generated on **Tue Oct 08 17:36:54 WEST 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).
This report was generated on **Thu Oct 10 18:03:17 WEST 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).



Expand Down Expand Up @@ -7361,7 +7361,7 @@ This report was generated on **Tue Oct 08 17:36:54 WEST 2024** using [Gradle-Lic

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

This report was generated on **Tue Oct 08 17:36:54 WEST 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).
This report was generated on **Thu Oct 10 18:03:18 WEST 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).



Expand Down Expand Up @@ -8082,7 +8082,7 @@ This report was generated on **Tue Oct 08 17:36:54 WEST 2024** using [Gradle-Lic

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

This report was generated on **Tue Oct 08 17:36:54 WEST 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).
This report was generated on **Thu Oct 10 18:03:18 WEST 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).



Expand Down Expand Up @@ -8842,7 +8842,7 @@ This report was generated on **Tue Oct 08 17:36:54 WEST 2024** using [Gradle-Lic

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

This report was generated on **Tue Oct 08 17:36:54 WEST 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).
This report was generated on **Thu Oct 10 18:03:18 WEST 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).



Expand Down Expand Up @@ -9481,7 +9481,7 @@ This report was generated on **Tue Oct 08 17:36:54 WEST 2024** using [Gradle-Lic

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

This report was generated on **Tue Oct 08 17:36:54 WEST 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).
This report was generated on **Thu Oct 10 18:03:18 WEST 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).



Expand Down Expand Up @@ -10202,7 +10202,7 @@ This report was generated on **Tue Oct 08 17:36:54 WEST 2024** using [Gradle-Lic

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

This report was generated on **Tue Oct 08 17:36:55 WEST 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).
This report was generated on **Thu Oct 10 18:03:18 WEST 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).



Expand Down Expand Up @@ -10966,7 +10966,7 @@ This report was generated on **Tue Oct 08 17:36:55 WEST 2024** using [Gradle-Lic

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

This report was generated on **Tue Oct 08 17:36:55 WEST 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).
This report was generated on **Thu Oct 10 18:03:18 WEST 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).



Expand Down Expand Up @@ -11721,7 +11721,7 @@ This report was generated on **Tue Oct 08 17:36:55 WEST 2024** using [Gradle-Lic

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

This report was generated on **Tue Oct 08 17:36:55 WEST 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).
This report was generated on **Thu Oct 10 18:03:19 WEST 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).



Expand Down Expand Up @@ -12555,7 +12555,7 @@ This report was generated on **Tue Oct 08 17:36:55 WEST 2024** using [Gradle-Lic

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

This report was generated on **Tue Oct 08 17:36:55 WEST 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).
This report was generated on **Thu Oct 10 18:03:19 WEST 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).



Expand Down Expand Up @@ -13389,4 +13389,4 @@ This report was generated on **Tue Oct 08 17:36:55 WEST 2024** using [Gradle-Lic

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

This report was generated on **Tue Oct 08 17:36:55 WEST 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).
This report was generated on **Thu Oct 10 18:03:19 WEST 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).
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ import io.spine.protodata.ast.Field
import io.spine.protodata.ast.event.TypeExited
import io.spine.protodata.plugin.Policy
import io.spine.protodata.value.Value
import io.spine.server.event.NoReaction
import io.spine.server.event.React
import io.spine.server.model.Nothing
import io.spine.server.event.asB
import io.spine.server.query.select
import io.spine.server.tuple.EitherOf2
import io.spine.validation.ComparisonOperator.LESS_THAN
Expand All @@ -49,10 +50,10 @@ import io.spine.validation.test.money.CurrencyType
public class CurrencyValidationPolicy : Policy<TypeExited>() {

@React
override fun whenever(@External event: TypeExited): EitherOf2<SimpleRuleAdded, Nothing> {
override fun whenever(@External event: TypeExited): EitherOf2<SimpleRuleAdded, NoReaction> {
val currencyType = select<CurrencyType>().findById(event.type)
if (currencyType == null || currencyType.hasCurrency().not()) {
return EitherOf2.withB(nothing())
return noReaction().asB()
}
val minorUnits = currencyType.minorUnitField
val otherValue = minorUnitsPerUnit(currencyType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import io.spine.validation.ErrorMessage
*
* The constraint applies to a `oneof` group and enforces an alternative to be set.
* The generated code checks that the `oneof`'s case is one of the alternatives,
* i.e., not not-set.
* i.e., the `oneof` is initialized with an option.
*/
internal class RequiredOneofGenerator(
private val name: OneofName,
Expand Down
8 changes: 4 additions & 4 deletions model/src/main/java/io/spine/validation/DistinctPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
import io.spine.core.Where;
import io.spine.protodata.ast.FieldName;
import io.spine.protodata.ast.File;
import io.spine.protodata.ast.event.FieldOptionDiscovered;
import io.spine.protodata.ast.TypeName;
import io.spine.protodata.ast.event.FieldOptionDiscovered;
import io.spine.server.event.NoReaction;
import io.spine.server.event.React;
import io.spine.server.model.Nothing;
import io.spine.server.tuple.EitherOf2;
import io.spine.validation.event.RuleAdded;
import io.spine.validation.event.SimpleRuleAdded;
Expand All @@ -59,12 +59,12 @@ final class DistinctPolicy extends ValidationPolicy<FieldOptionDiscovered> {

@Override
@React
protected EitherOf2<RuleAdded, Nothing> whenever(
protected EitherOf2<RuleAdded, NoReaction> whenever(
@External @Where(field = OPTION_NAME, equals = "distinct") FieldOptionDiscovered event
) {
var option = event.getOption();
if (!unpack(option.getValue(), BoolValue.class).getValue()) {
return noReaction();
return ignoring();
}
checkCollection(event.getField(), event.getType(), event.getFile());
var field = event.getField();
Expand Down
6 changes: 3 additions & 3 deletions model/src/main/java/io/spine/validation/RequiredPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import io.spine.protodata.ast.Field;
import io.spine.protodata.ast.event.FieldExited;
import io.spine.protodata.plugin.Policy;
import io.spine.server.event.NoReaction;
import io.spine.server.event.React;
import io.spine.server.model.Nothing;
import io.spine.server.tuple.EitherOf2;
import io.spine.validation.event.RuleAdded;

Expand All @@ -49,7 +49,7 @@ final class RequiredPolicy extends ValidationPolicy<FieldExited> {

@Override
@React
protected EitherOf2<RuleAdded, Nothing> whenever(@External FieldExited event) {
protected EitherOf2<RuleAdded, NoReaction> whenever(@External FieldExited event) {
var id = FieldId.newBuilder()
.setName(event.getField())
.setType(event.getType())
Expand All @@ -59,7 +59,7 @@ protected EitherOf2<RuleAdded, Nothing> whenever(@External FieldExited event) {
var declaration = findField(event.getField(), event.getType(), event.getFile(), this);
return EitherOf2.withA(requiredRule(declaration, field));
}
return noReaction();
return ignoring();
}

private static RuleAdded requiredRule(Field declaration, RequiredField field) {
Expand Down
6 changes: 3 additions & 3 deletions model/src/main/java/io/spine/validation/ValidatePolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import io.spine.protodata.ast.File;
import io.spine.protodata.ast.TypeName;
import io.spine.protodata.ast.event.FieldExited;
import io.spine.server.event.NoReaction;
import io.spine.server.event.React;
import io.spine.server.model.Nothing;
import io.spine.server.tuple.EitherOf2;
import io.spine.validation.event.RuleAdded;
import io.spine.validation.event.SimpleRuleAdded;
Expand All @@ -55,7 +55,7 @@ final class ValidatePolicy extends ValidationPolicy<FieldExited> {

@Override
@React
protected EitherOf2<RuleAdded, Nothing> whenever(@External FieldExited event) {
protected EitherOf2<RuleAdded, NoReaction> whenever(@External FieldExited event) {
var id = FieldId.newBuilder()
.setName(event.getField())
.setType(event.getType())
Expand All @@ -66,7 +66,7 @@ protected EitherOf2<RuleAdded, Nothing> whenever(@External FieldExited event) {
}
var shouldValidate = field != null && field.getValidate();
if (!shouldValidate) {
return noReaction();
return ignoring();
}
var rule = SimpleRules.withCustom(
event.getField(),
Expand Down
Loading
Loading