public final class Constraint extends com.google.protobuf.GeneratedMessageV3 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 | Class and Description |
|---|---|
static class |
Constraint.Builder
`Constraint` represents a validation rule written in the Common Expression
Language (CEL) syntax.
|
com.google.protobuf.GeneratedMessageV3.BuilderParent, com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<MessageT extends com.google.protobuf.GeneratedMessageV3.ExtendableMessage<MessageT>,BuilderT extends com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<MessageT,BuilderT>>, com.google.protobuf.GeneratedMessageV3.ExtendableMessage<MessageT extends com.google.protobuf.GeneratedMessageV3.ExtendableMessage<MessageT>>, com.google.protobuf.GeneratedMessageV3.ExtendableMessageOrBuilder<MessageT extends com.google.protobuf.GeneratedMessageV3.ExtendableMessage<MessageT>>, com.google.protobuf.GeneratedMessageV3.FieldAccessorTable, com.google.protobuf.GeneratedMessageV3.UnusedPrivateParameter| Modifier and Type | Field and Description |
|---|---|
static int |
EXPRESSION_FIELD_NUMBER |
static int |
ID_FIELD_NUMBER |
static int |
MESSAGE_FIELD_NUMBER |
| Modifier and Type | Method and Description |
|---|---|
static Constraint |
getDefaultInstance() |
Constraint |
getDefaultInstanceForType() |
static com.google.protobuf.Descriptors.Descriptor |
getDescriptor() |
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.
|
com.google.protobuf.Parser<Constraint> |
getParserForType() |
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable |
internalGetFieldAccessorTable() |
static Constraint.Builder |
newBuilder() |
static Constraint.Builder |
newBuilder(Constraint prototype) |
Constraint.Builder |
newBuilderForType() |
protected Constraint.Builder |
newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) |
protected Object |
newInstance(com.google.protobuf.GeneratedMessageV3.UnusedPrivateParameter unused) |
static Constraint |
parseDelimitedFrom(InputStream input) |
static Constraint |
parseDelimitedFrom(InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
static Constraint |
parseFrom(byte[] data) |
static Constraint |
parseFrom(byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
static Constraint |
parseFrom(ByteBuffer data) |
static Constraint |
parseFrom(ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
static Constraint |
parseFrom(com.google.protobuf.ByteString data) |
static Constraint |
parseFrom(com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
static Constraint |
parseFrom(com.google.protobuf.CodedInputStream input) |
static Constraint |
parseFrom(com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
static Constraint |
parseFrom(InputStream input) |
static Constraint |
parseFrom(InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
static com.google.protobuf.Parser<Constraint> |
parser() |
Constraint.Builder |
toBuilder() |
canUseUnsafe, computeStringSize, computeStringSizeNoTag, emptyBooleanList, emptyDoubleList, emptyFloatList, emptyIntList, emptyList, emptyLongList, getAllFields, getDescriptorForType, getField, getOneofFieldDescriptor, getRepeatedField, getRepeatedFieldCount, getSerializedSize, getUnknownFields, hasField, hasOneof, internalGetMapField, internalGetMapFieldReflection, isInitialized, isStringEmpty, makeExtensionsImmutable, makeMutableCopy, makeMutableCopy, mergeFromAndMakeImmutableInternal, mutableCopy, mutableCopy, mutableCopy, mutableCopy, mutableCopy, newBooleanList, newBuilderForType, newDoubleList, newFloatList, newIntList, newLongList, parseDelimitedWithIOException, parseDelimitedWithIOException, parseUnknownField, parseUnknownFieldProto3, parseWithIOException, parseWithIOException, parseWithIOException, parseWithIOException, serializeBooleanMapTo, serializeIntegerMapTo, serializeLongMapTo, serializeStringMapTo, writeReplace, writeString, writeStringNoTag, writeToequals, findInitializationErrors, getInitializationErrorString, hashBoolean, hashCode, hashEnum, hashEnumList, hashFields, hashLong, toStringaddAll, addAll, checkByteStringIsUtf8, toByteArray, toByteString, writeDelimitedTo, writeToclone, finalize, getClass, notify, notifyAll, wait, wait, waitpublic static final int ID_FIELD_NUMBER
public static final int MESSAGE_FIELD_NUMBER
public static final int EXPRESSION_FIELD_NUMBER
protected Object newInstance(com.google.protobuf.GeneratedMessageV3.UnusedPrivateParameter unused)
newInstance in class com.google.protobuf.GeneratedMessageV3public static final com.google.protobuf.Descriptors.Descriptor getDescriptor()
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
internalGetFieldAccessorTable in class com.google.protobuf.GeneratedMessageV3public 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 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 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 static Constraint parseFrom(ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException
com.google.protobuf.InvalidProtocolBufferExceptionpublic static Constraint parseFrom(ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException
com.google.protobuf.InvalidProtocolBufferExceptionpublic static Constraint parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException
com.google.protobuf.InvalidProtocolBufferExceptionpublic static Constraint parseFrom(com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException
com.google.protobuf.InvalidProtocolBufferExceptionpublic static Constraint parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException
com.google.protobuf.InvalidProtocolBufferExceptionpublic static Constraint parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException
com.google.protobuf.InvalidProtocolBufferExceptionpublic static Constraint parseFrom(InputStream input) throws IOException
IOExceptionpublic static Constraint parseFrom(InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws IOException
IOExceptionpublic static Constraint parseDelimitedFrom(InputStream input) throws IOException
IOExceptionpublic static Constraint parseDelimitedFrom(InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws IOException
IOExceptionpublic static Constraint parseFrom(com.google.protobuf.CodedInputStream input) throws IOException
IOExceptionpublic static Constraint parseFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws IOException
IOExceptionpublic Constraint.Builder newBuilderForType()
newBuilderForType in interface com.google.protobuf.MessagenewBuilderForType in interface com.google.protobuf.MessageLitepublic static Constraint.Builder newBuilder()
public static Constraint.Builder newBuilder(Constraint prototype)
public Constraint.Builder toBuilder()
toBuilder in interface com.google.protobuf.MessagetoBuilder in interface com.google.protobuf.MessageLiteprotected Constraint.Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent)
newBuilderForType in class com.google.protobuf.GeneratedMessageV3public static Constraint getDefaultInstance()
public static com.google.protobuf.Parser<Constraint> parser()
public com.google.protobuf.Parser<Constraint> getParserForType()
getParserForType in interface com.google.protobuf.MessagegetParserForType in interface com.google.protobuf.MessageLitegetParserForType in class com.google.protobuf.GeneratedMessageV3public Constraint getDefaultInstanceForType()
getDefaultInstanceForType in interface com.google.protobuf.MessageLiteOrBuildergetDefaultInstanceForType in interface com.google.protobuf.MessageOrBuilderCopyright © 2023. All rights reserved.