Skip to content

Commit dd07c6e

Browse files
committed
Make it so that you can define expression-only rules
Signed-off-by: Sri Krishna <[email protected]>
1 parent c2a0db2 commit dd07c6e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

protovalidate/internal/rules.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,16 @@ def _validate_cel(
348348
result = cel.runner.evaluate(activation)
349349
if isinstance(result, celtypes.BoolType):
350350
if not result:
351+
message = cel.rule.message
352+
if len(message) == 0:
353+
message = "\"{}\" returned false".format(cel.rule.expression)
351354
ctx.add(
352355
Violation(
353356
field_value=this_value,
354357
rule=cel.rule_path,
355358
rule_value=cel.rule_value,
356359
rule_id=cel.rule.id,
357-
message=cel.rule.message,
360+
message=message,
358361
for_key=for_key,
359362
),
360363
)

0 commit comments

Comments
 (0)