protovalidate icon indicating copy to clipboard operation
protovalidate copied to clipboard

[Feature Request] unique repeated messages by field

Open derekperkins opened this issue 9 months ago • 6 comments

Feature description: There's already a built in rule for scalar uniqueness in repeated fields. Most repeated messages have an id field that defines uniqueness, that could be used. https://github.com/bufbuild/protovalidate/blob/main/proto/protovalidate/buf/validate/validate.proto#L3199-L3213

Proposed implementation or solution:

This isn't valid CEL, just a rough description of what I'm expecting

  optional bool unique = 3 [(priv.field).cel = {
    id: "repeated.unique_by_field"
    message: "repeated value must contain unique items, identified by an id field"
    expression: "this.unique(this.unique_id)"
  }];

Contribution: Minimal time to contribute currently

derekperkins avatar Sep 18 '23 20:09 derekperkins