public static final class Constraint.Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder> implements ConstraintOrBuilder
`Constraint` represents a validation rule written in the Common Expression
Language (CEL) syntax. Each Constraint includes a unique identifier, an
optional error message, and the CEL expression to evaluate. For more
information on CEL, [see our documentation](https://github.com/bufbuild/protovalidate/blob/main/docs/cel.md).
```proto
message Foo {
option (buf.validate.message).cel = {
id: "foo.bar"
message: "bar must be greater than 0"
expression: "this.bar > 0"
};
int32 bar = 1;
}
```
Protobuf type buf.validate.Constraint| Modifier and Type | Method and Description |
|---|---|
Constraint.Builder |
addRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) |
Constraint |
build() |
Constraint |
buildPartial() |
Constraint.Builder |
clear() |
Constraint.Builder |
clearExpression()
`expression` is the actual CEL expression that will be evaluated for
validation.
|
Constraint.Builder |
clearField(com.google.protobuf.Descriptors.FieldDescriptor field) |
Constraint.Builder |
clearId()
`id` is a string that serves as a machine-readable name for this Constraint.
|
Constraint.Builder |
clearMessage()
`message` is an optional field that provides a human-readable error message
for this Constraint when the CEL expression evaluates to false.
|
Constraint.Builder |
clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) |
Constraint.Builder |
clone() |
Constraint |
getDefaultInstanceForType() |
static com.google.protobuf.Descriptors.Descriptor |
getDescriptor() |
com.google.protobuf.Descriptors.Descriptor |
getDescriptorForType() |
String |
getExpression()
`expression` is the actual CEL expression that will be evaluated for
validation.
|
com.google.protobuf.ByteString |
getExpressionBytes()
`expression` is the actual CEL expression that will be evaluated for
validation.
|
String |
getId()
`id` is a string that serves as a machine-readable name for this Constraint.
|
com.google.protobuf.ByteString |
getIdBytes()
`id` is a string that serves as a machine-readable name for this Constraint.
|
String |
getMessage()
`message` is an optional field that provides a human-readable error message
for this Constraint when the CEL expression evaluates to false.
|
com.google.protobuf.ByteString |
getMessageBytes()
`message` is an optional field that provides a human-readable error message
for this Constraint when the CEL expression evaluates to false.
|
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable |
internalGetFieldAccessorTable() |
Constraint.Builder |
mergeUnknownFields(com.google.protobuf.UnknownFieldSet unknownFields) |
Constraint.Builder |
setExpression(String value)
`expression` is the actual CEL expression that will be evaluated for
validation.
|
Constraint.Builder |
setExpressionBytes(com.google.protobuf.ByteString value)
`expression` is the actual CEL expression that will be evaluated for
validation.
|
Constraint.Builder |
setField(com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) |
Constraint.Builder |
setId(String value)
`id` is a string that serves as a machine-readable name for this Constraint.
|
Constraint.Builder |
setIdBytes(com.google.protobuf.ByteString value)
`id` is a string that serves as a machine-readable name for this Constraint.
|
Constraint.Builder |
setMessage(String value)
`message` is an optional field that provides a human-readable error message
for this Constraint when the CEL expression evaluates to false.
|
Constraint.Builder |
setMessageBytes(com.google.protobuf.ByteString value)
`message` is an optional field that provides a human-readable error message
for this Constraint when the CEL expression evaluates to false.
|
Constraint.Builder |
setRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field,
int index,
Object value) |
Constraint.Builder |
setUnknownFields(com.google.protobuf.UnknownFieldSet unknownFields) |
getAllFields, getField, getFieldBuilder, getOneofFieldDescriptor, getParentForChildren, getRepeatedField, getRepeatedFieldBuilder, getRepeatedFieldCount, getUnknownFields, getUnknownFieldSetBuilder, hasField, hasOneof, internalGetMapField, internalGetMapFieldReflection, internalGetMutableMapField, internalGetMutableMapFieldReflection, isClean, isInitialized, markClean, mergeUnknownLengthDelimitedField, mergeUnknownVarintField, newBuilderForField, onBuilt, onChanged, parseUnknownField, setUnknownFieldSetBuilder, setUnknownFieldsProto3findInitializationErrors, getInitializationErrorString, internalMergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, newUninitializedMessageException, toStringaddAll, addAll, mergeDelimitedFrom, mergeDelimitedFrom, newUninitializedMessageExceptionequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitpublic static final com.google.protobuf.Descriptors.Descriptor getDescriptor()
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
internalGetFieldAccessorTable in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>public Constraint.Builder clear()
clear in interface com.google.protobuf.Message.Builderclear in interface com.google.protobuf.MessageLite.Builderclear in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>public com.google.protobuf.Descriptors.Descriptor getDescriptorForType()
getDescriptorForType in interface com.google.protobuf.Message.BuildergetDescriptorForType in interface com.google.protobuf.MessageOrBuildergetDescriptorForType in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>public Constraint getDefaultInstanceForType()
getDefaultInstanceForType in interface com.google.protobuf.MessageLiteOrBuildergetDefaultInstanceForType in interface com.google.protobuf.MessageOrBuilderpublic Constraint build()
build in interface com.google.protobuf.Message.Builderbuild in interface com.google.protobuf.MessageLite.Builderpublic Constraint buildPartial()
buildPartial in interface com.google.protobuf.Message.BuilderbuildPartial in interface com.google.protobuf.MessageLite.Builderpublic Constraint.Builder clone()
clone in interface com.google.protobuf.Message.Builderclone in interface com.google.protobuf.MessageLite.Builderclone in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>public Constraint.Builder setField(com.google.protobuf.Descriptors.FieldDescriptor field, Object value)
setField in interface com.google.protobuf.Message.BuildersetField in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>public Constraint.Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field)
clearField in interface com.google.protobuf.Message.BuilderclearField in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>public Constraint.Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof)
clearOneof in interface com.google.protobuf.Message.BuilderclearOneof in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>public Constraint.Builder setRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, int index, Object value)
setRepeatedField in interface com.google.protobuf.Message.BuildersetRepeatedField in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>public Constraint.Builder addRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, Object value)
addRepeatedField in interface com.google.protobuf.Message.BuilderaddRepeatedField in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>public String getId()
`id` is a string that serves as a machine-readable name for this Constraint. It should be unique within its scope, which could be either a message or a field.
string id = 1 [json_name = "id"];getId in interface ConstraintOrBuilderpublic com.google.protobuf.ByteString getIdBytes()
`id` is a string that serves as a machine-readable name for this Constraint. It should be unique within its scope, which could be either a message or a field.
string id = 1 [json_name = "id"];getIdBytes in interface ConstraintOrBuilderpublic Constraint.Builder setId(String value)
`id` is a string that serves as a machine-readable name for this Constraint. It should be unique within its scope, which could be either a message or a field.
string id = 1 [json_name = "id"];value - The id to set.public Constraint.Builder clearId()
`id` is a string that serves as a machine-readable name for this Constraint. It should be unique within its scope, which could be either a message or a field.
string id = 1 [json_name = "id"];public Constraint.Builder setIdBytes(com.google.protobuf.ByteString value)
`id` is a string that serves as a machine-readable name for this Constraint. It should be unique within its scope, which could be either a message or a field.
string id = 1 [json_name = "id"];value - The bytes for id to set.public String getMessage()
`message` is an optional field that provides a human-readable error message for this Constraint when the CEL expression evaluates to false. If a non-empty message is provided, any strings resulting from the CEL expression evaluation are ignored.
string message = 2 [json_name = "message"];getMessage in interface ConstraintOrBuilderpublic com.google.protobuf.ByteString getMessageBytes()
`message` is an optional field that provides a human-readable error message for this Constraint when the CEL expression evaluates to false. If a non-empty message is provided, any strings resulting from the CEL expression evaluation are ignored.
string message = 2 [json_name = "message"];getMessageBytes in interface ConstraintOrBuilderpublic Constraint.Builder setMessage(String value)
`message` is an optional field that provides a human-readable error message for this Constraint when the CEL expression evaluates to false. If a non-empty message is provided, any strings resulting from the CEL expression evaluation are ignored.
string message = 2 [json_name = "message"];value - The message to set.public Constraint.Builder clearMessage()
`message` is an optional field that provides a human-readable error message for this Constraint when the CEL expression evaluates to false. If a non-empty message is provided, any strings resulting from the CEL expression evaluation are ignored.
string message = 2 [json_name = "message"];public Constraint.Builder setMessageBytes(com.google.protobuf.ByteString value)
`message` is an optional field that provides a human-readable error message for this Constraint when the CEL expression evaluates to false. If a non-empty message is provided, any strings resulting from the CEL expression evaluation are ignored.
string message = 2 [json_name = "message"];value - The bytes for message to set.public String getExpression()
`expression` is the actual CEL expression that will be evaluated for validation. This string must resolve to either a boolean or a string value. If the expression evaluates to false or a non-empty string, the validation is considered failed, and the message is rejected.
string expression = 3 [json_name = "expression"];getExpression in interface ConstraintOrBuilderpublic com.google.protobuf.ByteString getExpressionBytes()
`expression` is the actual CEL expression that will be evaluated for validation. This string must resolve to either a boolean or a string value. If the expression evaluates to false or a non-empty string, the validation is considered failed, and the message is rejected.
string expression = 3 [json_name = "expression"];getExpressionBytes in interface ConstraintOrBuilderpublic Constraint.Builder setExpression(String value)
`expression` is the actual CEL expression that will be evaluated for validation. This string must resolve to either a boolean or a string value. If the expression evaluates to false or a non-empty string, the validation is considered failed, and the message is rejected.
string expression = 3 [json_name = "expression"];value - The expression to set.public Constraint.Builder clearExpression()
`expression` is the actual CEL expression that will be evaluated for validation. This string must resolve to either a boolean or a string value. If the expression evaluates to false or a non-empty string, the validation is considered failed, and the message is rejected.
string expression = 3 [json_name = "expression"];public Constraint.Builder setExpressionBytes(com.google.protobuf.ByteString value)
`expression` is the actual CEL expression that will be evaluated for validation. This string must resolve to either a boolean or a string value. If the expression evaluates to false or a non-empty string, the validation is considered failed, and the message is rejected.
string expression = 3 [json_name = "expression"];value - The bytes for expression to set.public final Constraint.Builder setUnknownFields(com.google.protobuf.UnknownFieldSet unknownFields)
setUnknownFields in interface com.google.protobuf.Message.BuildersetUnknownFields in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>public final Constraint.Builder mergeUnknownFields(com.google.protobuf.UnknownFieldSet unknownFields)
mergeUnknownFields in interface com.google.protobuf.Message.BuildermergeUnknownFields in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>Copyright © 2024. All rights reserved.