Validate cardinality on multilang strings #32

Open
opened 2026-01-29 21:17:19 +00:00 by scossu · 0 comments
Owner

Setting a property as multi-language in a schema disables the max cardinality check, because calculating the cardinality in such cases is a bit trickier.

The max cardinality check should be implemented for multilang properties in the following way:

  • Find all values of the property in question;
  • Group them by language tags, including the untagged values (e.g. build a table with lang tags as keys and a list of untagged values as values);
  • Calculate the max size of each group of same-language strings;
  • Verify if this size exceeds the max cardinality constraint.

The minimum cardinality is conceptually more complex, because we cannot distinguish if the cardinality must be checked for all the languages, and because the untagged values can be always used as a fallback. Also, we will never know which languages will be requested, and whether those languages are in the provided data.

Because of that, the safest approach is to compare the minimum cardinality against the size of the untagged values (using the previously described table used for the max cardinality).

Content admins should be recommended to not set the minimum cardinality for multilang properties to more than 1, to avoid confusing the hell out of their users.

Setting a property as multi-language in a schema disables the max cardinality check, because calculating the cardinality in such cases is a bit trickier. The max cardinality check should be implemented for multilang properties in the following way: - Find all values of the property in question; - Group them by language tags, including the untagged values (e.g. build a table with lang tags as keys and a list of untagged values as values); - Calculate the max size of each group of same-language strings; - Verify if this size exceeds the max cardinality constraint. The minimum cardinality is conceptually more complex, because we cannot distinguish if the cardinality must be checked for all the languages, and because the untagged values can be always used as a fallback. Also, we will never know which languages will be requested, and whether those languages are in the provided data. Because of that, the safest approach is to compare the minimum cardinality against the size of the untagged values (using the previously described table used for the max cardinality). Content admins should be recommended to not set the minimum cardinality for multilang properties to more than 1, to avoid confusing the hell out of their users.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
scossu/pocket_archive#32
No description provided.