A map<K, string> field marked with (required) currently accepts an entry whose value is an empty string. Such an entry is effectively "empty" and should be treated the same as having no entries at all for the purpose of the (required) constraint.
Consider this scenario from RequiredMapWithStringsITest:
val empty = Collections.newBuilder()
.putContainsANonEmptyStringValue("", "")
.putNotEmptyMapOfInts(111, 314)
.addAtLeastOnePieceOfMeat(UltimateChoice.FISH)
.addNotEmptyListOfLongs(42L)
assertInvalid(empty)
The above currently passes validation because the map contains one entry, even though that entry carries no information. The test prohibit an entry with empty string is @Disabled until we decide on the semantics.
Proposed behaviour
An entry with an empty string value in a (required) map should be considered as not satisfying the (required) constraint — by analogy with the way an empty string in a (required) string field is rejected.
An empty string key should be accepted even if (required) option is used.
Files
tests/validating/src/test/kotlin/io/spine/test/options/required/RequiredMapWithStringsITest.kt
Tasks
A
map<K, string>field marked with(required)currently accepts an entry whose value is an empty string. Such an entry is effectively "empty" and should be treated the same as having no entries at all for the purpose of the(required)constraint.Consider this scenario from
RequiredMapWithStringsITest:The above currently passes validation because the map contains one entry, even though that entry carries no information. The test
prohibit an entry with empty stringis@Disableduntil we decide on the semantics.Proposed behaviour
An entry with an empty string value in a
(required)map should be considered as not satisfying the(required)constraint — by analogy with the way an empty string in a(required)stringfield is rejected.An empty string key should be accepted even if
(required)option is used.Files
tests/validating/src/test/kotlin/io/spine/test/options/required/RequiredMapWithStringsITest.ktTasks
(required).prohibit an entry with empty stringtest.(required)option inspine/options.protoin Spine Base (../base-libraries/base) describes the required map key behavior. If not, update.