@@ -127,8 +127,8 @@ absl::Status MessageConstraintRules::Validate(
127127absl::Status FieldConstraintRules::Validate (
128128 ConstraintContext& ctx, const google::protobuf::Message& message) const {
129129 static const google::protobuf::FieldDescriptor* requiredField =
130- FieldConstraints ::descriptor ()->FindFieldByNumber (
131- FieldConstraints ::kRequiredFieldNumber );
130+ FieldRules ::descriptor ()->FindFieldByNumber (
131+ FieldRules ::kRequiredFieldNumber );
132132 google::api::expr::runtime::Activation activation;
133133 cel::runtime::CelValue result;
134134 std::string subPath;
@@ -141,11 +141,11 @@ absl::Status FieldConstraintRules::Validate(
141141 return absl::OkStatus ();
142142 } else if (required_) {
143143 Violation violation;
144- *violation.mutable_constraint_id () = " required" ;
144+ *violation.mutable_rule_id () = " required" ;
145145 *violation.mutable_message () = " value is required" ;
146146 *violation.mutable_field ()->mutable_elements ()->Add () = fieldPathElement (field_);
147147 *violation.mutable_rule ()->mutable_elements ()->Add () =
148- staticFieldPathElement<FieldConstraints, FieldConstraints ::kRequiredFieldNumber >();
148+ staticFieldPathElement<FieldRules, FieldRules ::kRequiredFieldNumber >();
149149 ctx.violations .emplace_back (
150150 std::move (violation),
151151 ProtoField{&message, field_},
@@ -161,11 +161,11 @@ absl::Status FieldConstraintRules::Validate(
161161 return absl::OkStatus ();
162162 } else if (required_) {
163163 Violation violation;
164- *violation.mutable_constraint_id () = " required" ;
164+ *violation.mutable_rule_id () = " required" ;
165165 *violation.mutable_message () = " value is required" ;
166166 *violation.mutable_field ()->mutable_elements ()->Add () = fieldPathElement (field_);
167167 *violation.mutable_rule ()->mutable_elements ()->Add () =
168- staticFieldPathElement<FieldConstraints, FieldConstraints ::kRequiredFieldNumber >();
168+ staticFieldPathElement<FieldRules, FieldRules ::kRequiredFieldNumber >();
169169 ctx.violations .emplace_back (
170170 std::move (violation),
171171 ProtoField{&message, field_},
@@ -176,11 +176,11 @@ absl::Status FieldConstraintRules::Validate(
176176 if (!message.GetReflection ()->HasField (message, field_)) {
177177 if (required_) {
178178 Violation violation;
179- *violation.mutable_constraint_id () = " required" ;
179+ *violation.mutable_rule_id () = " required" ;
180180 *violation.mutable_message () = " value is required" ;
181181 *violation.mutable_field ()->mutable_elements ()->Add () = fieldPathElement (field_);
182182 *violation.mutable_rule ()->mutable_elements ()->Add () =
183- staticFieldPathElement<FieldConstraints, FieldConstraints ::kRequiredFieldNumber >();
183+ staticFieldPathElement<FieldRules, FieldRules ::kRequiredFieldNumber >();
184184 ctx.violations .emplace_back (
185185 std::move (violation),
186186 ProtoField{&message, field_},
@@ -235,11 +235,11 @@ absl::Status EnumConstraintRules::Validate(
235235 auto value = message.GetReflection ()->GetEnumValue (message, field_);
236236 if (field_->enum_type ()->FindValueByNumber (value) == nullptr ) {
237237 Violation violation;
238- *violation.mutable_constraint_id () = " enum.defined_only" ;
238+ *violation.mutable_rule_id () = " enum.defined_only" ;
239239 *violation.mutable_message () = " value must be one of the defined enum values" ;
240240 *violation.mutable_field ()->mutable_elements ()->Add () = fieldPathElement (field_);
241241 *violation.mutable_rule ()->mutable_elements ()->Add () = fieldPathElement (EnumRules::descriptor ()->FindFieldByNumber (EnumRules::kDefinedOnlyFieldNumber ));
242- *violation.mutable_rule ()->mutable_elements ()->Add () = fieldPathElement (FieldConstraints ::descriptor ()->FindFieldByNumber (FieldConstraints ::kEnumFieldNumber ));
242+ *violation.mutable_rule ()->mutable_elements ()->Add () = fieldPathElement (FieldRules ::descriptor ()->FindFieldByNumber (FieldRules ::kEnumFieldNumber ));
243243 ctx.violations .emplace_back (
244244 std::move (violation),
245245 ProtoField{&message, field_},
@@ -280,7 +280,7 @@ absl::Status RepeatedConstraintRules::Validate(
280280 ctx.appendFieldPathElement (element, pos);
281281 ctx.appendRulePathElement ({
282282 fieldPathElement (RepeatedRules::descriptor ()->FindFieldByNumber (RepeatedRules::kItemsFieldNumber )),
283- fieldPathElement (FieldConstraints ::descriptor ()->FindFieldByNumber (FieldConstraints ::kRepeatedFieldNumber )),
283+ fieldPathElement (FieldRules ::descriptor ()->FindFieldByNumber (FieldRules ::kRepeatedFieldNumber )),
284284 }, pos);
285285 ctx.setFieldValue (ProtoField{&message, field_, i}, pos);
286286 }
@@ -320,7 +320,7 @@ absl::Status MapConstraintRules::Validate(
320320 if (ctx.violations .size () > pos) {
321321 ctx.appendRulePathElement ({
322322 fieldPathElement (MapRules::descriptor ()->FindFieldByNumber (MapRules::kKeysFieldNumber )),
323- fieldPathElement (FieldConstraints ::descriptor ()->FindFieldByNumber (FieldConstraints ::kMapFieldNumber )),
323+ fieldPathElement (FieldRules ::descriptor ()->FindFieldByNumber (FieldRules ::kMapFieldNumber )),
324324 }, pos);
325325 ctx.setFieldValue (ProtoField{&elemMsg, keyField}, pos);
326326 ctx.setForKey (pos);
@@ -340,7 +340,7 @@ absl::Status MapConstraintRules::Validate(
340340 if (ctx.violations .size () > valuePos) {
341341 ctx.appendRulePathElement ({
342342 fieldPathElement (MapRules::descriptor ()->FindFieldByNumber (MapRules::kValuesFieldNumber )),
343- fieldPathElement (FieldConstraints ::descriptor ()->FindFieldByNumber (FieldConstraints ::kMapFieldNumber )),
343+ fieldPathElement (FieldRules ::descriptor ()->FindFieldByNumber (FieldRules ::kMapFieldNumber )),
344344 }, valuePos);
345345 ctx.setFieldValue (ProtoField{&elemMsg, valueField}, pos);
346346 }
@@ -389,15 +389,15 @@ absl::Status FieldConstraintRules::ValidateAny(
389389 }
390390 if (!found) {
391391 Violation violation;
392- *violation.mutable_constraint_id () = " any.in" ;
392+ *violation.mutable_rule_id () = " any.in" ;
393393 *violation.mutable_message () = " type URL must be in the allow list" ;
394394 if (field.index () == -1 ) {
395395 *violation.mutable_field ()->mutable_elements ()->Add () = fieldPathElement (field.descriptor ());
396396 }
397397 *violation.mutable_rule ()->mutable_elements ()->Add () =
398398 staticFieldPathElement<AnyRules, AnyRules::kInFieldNumber >();
399399 *violation.mutable_rule ()->mutable_elements ()->Add () =
400- staticFieldPathElement<FieldConstraints, FieldConstraints ::kAnyFieldNumber >();
400+ staticFieldPathElement<FieldRules, FieldRules ::kAnyFieldNumber >();
401401 ctx.violations .emplace_back (
402402 std::move (violation),
403403 field,
@@ -407,15 +407,15 @@ absl::Status FieldConstraintRules::ValidateAny(
407407 for (const auto & block : anyRules_->not_in ()) {
408408 if (block == typeUri) {
409409 Violation violation;
410- *violation.mutable_constraint_id () = " any.not_in" ;
410+ *violation.mutable_rule_id () = " any.not_in" ;
411411 *violation.mutable_message () = " type URL must not be in the block list" ;
412412 if (field.index () == -1 ) {
413413 *violation.mutable_field ()->mutable_elements ()->Add () = fieldPathElement (field.descriptor ());
414414 }
415415 *violation.mutable_rule ()->mutable_elements ()->Add () =
416416 staticFieldPathElement<AnyRules, AnyRules::kNotInFieldNumber >();
417417 *violation.mutable_rule ()->mutable_elements ()->Add () =
418- staticFieldPathElement<FieldConstraints, FieldConstraints ::kAnyFieldNumber >();
418+ staticFieldPathElement<FieldRules, FieldRules ::kAnyFieldNumber >();
419419 ctx.violations .emplace_back (
420420 std::move (violation),
421421 field,
@@ -432,7 +432,7 @@ absl::Status OneofConstraintRules::Validate(
432432 if (required_) {
433433 if (!message.GetReflection ()->HasOneof (message, oneof_)) {
434434 Violation violation;
435- *violation.mutable_constraint_id () = " required" ;
435+ *violation.mutable_rule_id () = " required" ;
436436 *violation.mutable_message () = " exactly one field is required in oneof" ;
437437 *violation.mutable_field ()->mutable_elements ()->Add () = oneofPathElement (*oneof_);
438438 ctx.violations .emplace_back (std::move (violation), absl::nullopt , absl::nullopt );
0 commit comments