#Hello again, a simple question, how to
1 messages · Page 1 of 1 (latest)
@lean tapir you can define a rule that verifies the length of the array. Here's an example of how you can achieve this by creating a rule in your schema:
entity entity_name {
attribute attribute_name string
// Example permission using the rule
permission example_permission = is_not_empty(attribute_name)
}
rule is_not_empty(attribute_name string) {
len(attribute_name) > 0
}
Thanks len function. Is this documented somewhere, just wondering if I am missing any reference
Hi, I came up with the len function but had a conversation with the team and they corrected me. We have .size function instead.
Also they propose additional approach:
entity entity_name {
attribute attribute_name string[]
// Example permission using the rule
permission example_permission = is_not_empty(attribute_name)
}
rule is_not_empty(attribute_name string[]) {
attribute_name.size() > 0
}
Could you try this one.