Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement predefined field constraints #189

Merged
merged 7 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ADD_LICENSE_HEADER := $(BIN)/license-header \
--license-type apache \
--copyright-holder "Buf Technologies, Inc." \
--year-range "2023"
PROTOVALIDATE_VERSION ?= v0.7.1
PROTOVALIDATE_VERSION ?= v0.8.1

.PHONY: help
help: ## Describe useful make targets
Expand Down
6 changes: 5 additions & 1 deletion gen/buf/validate/conformance/cases/bool_pb2.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from buf.validate import validate_pb2 as buf_dot_validate_dot_validate__pb2


DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n)buf/validate/conformance/cases/bool.proto\x12\x1e\x62uf.validate.conformance.cases\x1a\x1b\x62uf/validate/validate.proto\"\x1c\n\x08\x42oolNone\x12\x10\n\x03val\x18\x01 \x01(\x08R\x03val\"*\n\rBoolConstTrue\x12\x19\n\x03val\x18\x01 \x01(\x08\x42\x07\xbaH\x04j\x02\x08\x01R\x03val\"+\n\x0e\x42oolConstFalse\x12\x19\n\x03val\x18\x01 \x01(\x08\x42\x07\xbaH\x04j\x02\x08\x00R\x03valb\x06proto3')
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n)buf/validate/conformance/cases/bool.proto\x12\x1e\x62uf.validate.conformance.cases\x1a\x1b\x62uf/validate/validate.proto\"\x1c\n\x08\x42oolNone\x12\x10\n\x03val\x18\x01 \x01(\x08R\x03val\"*\n\rBoolConstTrue\x12\x19\n\x03val\x18\x01 \x01(\x08\x42\x07\xbaH\x04j\x02\x08\x01R\x03val\"+\n\x0e\x42oolConstFalse\x12\x19\n\x03val\x18\x01 \x01(\x08\x42\x07\xbaH\x04j\x02\x08\x00R\x03val\"(\n\x0b\x42oolExample\x12\x19\n\x03val\x18\x01 \x01(\x08\x42\x07\xbaH\x04j\x02\x10\x01R\x03valb\x06proto3')

_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
Expand All @@ -50,10 +50,14 @@
_globals['_BOOLCONSTTRUE'].fields_by_name['val']._serialized_options = b'\272H\004j\002\010\001'
_globals['_BOOLCONSTFALSE'].fields_by_name['val']._loaded_options = None
_globals['_BOOLCONSTFALSE'].fields_by_name['val']._serialized_options = b'\272H\004j\002\010\000'
_globals['_BOOLEXAMPLE'].fields_by_name['val']._loaded_options = None
_globals['_BOOLEXAMPLE'].fields_by_name['val']._serialized_options = b'\272H\004j\002\020\001'
_globals['_BOOLNONE']._serialized_start=106
_globals['_BOOLNONE']._serialized_end=134
_globals['_BOOLCONSTTRUE']._serialized_start=136
_globals['_BOOLCONSTTRUE']._serialized_end=178
_globals['_BOOLCONSTFALSE']._serialized_start=180
_globals['_BOOLCONSTFALSE']._serialized_end=223
_globals['_BOOLEXAMPLE']._serialized_start=225
_globals['_BOOLEXAMPLE']._serialized_end=265
# @@protoc_insertion_point(module_scope)
6 changes: 6 additions & 0 deletions gen/buf/validate/conformance/cases/bool_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ class BoolConstFalse(_message.Message):
VAL_FIELD_NUMBER: _ClassVar[int]
val: bool
def __init__(self, val: bool = ...) -> None: ...

class BoolExample(_message.Message):
__slots__ = ("val",)
VAL_FIELD_NUMBER: _ClassVar[int]
val: bool
def __init__(self, val: bool = ...) -> None: ...
30 changes: 23 additions & 7 deletions gen/buf/validate/conformance/cases/bytes_pb2.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from buf.validate import validate_pb2 as buf_dot_validate_dot_validate__pb2


DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n*buf/validate/conformance/cases/bytes.proto\x12\x1e\x62uf.validate.conformance.cases\x1a\x1b\x62uf/validate/validate.proto\"\x1d\n\tBytesNone\x12\x10\n\x03val\x18\x01 \x01(\x0cR\x03val\"*\n\nBytesConst\x12\x1c\n\x03val\x18\x01 \x01(\x0c\x42\n\xbaH\x07z\x05\n\x03\x66ooR\x03val\",\n\x07\x42ytesIn\x12!\n\x03val\x18\x01 \x01(\x0c\x42\x0f\xbaH\x0cz\nB\x03\x62\x61rB\x03\x62\x61zR\x03val\"1\n\nBytesNotIn\x12#\n\x03val\x18\x01 \x01(\x0c\x42\x11\xbaH\x0ez\x0cJ\x04\x66izzJ\x04\x62uzzR\x03val\"%\n\x08\x42ytesLen\x12\x19\n\x03val\x18\x01 \x01(\x0c\x42\x07\xbaH\x04z\x02h\x03R\x03val\"(\n\x0b\x42ytesMinLen\x12\x19\n\x03val\x18\x01 \x01(\x0c\x42\x07\xbaH\x04z\x02\x10\x03R\x03val\"(\n\x0b\x42ytesMaxLen\x12\x19\n\x03val\x18\x01 \x01(\x0c\x42\x07\xbaH\x04z\x02\x18\x05R\x03val\"-\n\x0e\x42ytesMinMaxLen\x12\x1b\n\x03val\x18\x01 \x01(\x0c\x42\t\xbaH\x06z\x04\x10\x03\x18\x05R\x03val\"2\n\x13\x42ytesEqualMinMaxLen\x12\x1b\n\x03val\x18\x01 \x01(\x0c\x42\t\xbaH\x06z\x04\x10\x05\x18\x05R\x03val\"7\n\x0c\x42ytesPattern\x12\'\n\x03val\x18\x01 \x01(\x0c\x42\x15\xbaH\x12z\x10\"\x0e^[\\x00-\\x7F]+$R\x03val\")\n\x0b\x42ytesPrefix\x12\x1a\n\x03val\x18\x01 \x01(\x0c\x42\x08\xbaH\x05z\x03*\x01\x99R\x03val\"-\n\rBytesContains\x12\x1c\n\x03val\x18\x01 \x01(\x0c\x42\n\xbaH\x07z\x05:\x03\x62\x61rR\x03val\",\n\x0b\x42ytesSuffix\x12\x1d\n\x03val\x18\x01 \x01(\x0c\x42\x0b\xbaH\x08z\x06\x32\x04\x62uzzR\x03val\"$\n\x07\x42ytesIP\x12\x19\n\x03val\x18\x01 \x01(\x0c\x42\x07\xbaH\x04z\x02P\x01R\x03val\"&\n\tBytesIPv4\x12\x19\n\x03val\x18\x01 \x01(\x0c\x42\x07\xbaH\x04z\x02X\x01R\x03val\"&\n\tBytesIPv6\x12\x19\n\x03val\x18\x01 \x01(\x0c\x42\x07\xbaH\x04z\x02`\x01R\x03val\"/\n\x0f\x42ytesIPv6Ignore\x12\x1c\n\x03val\x18\x01 \x01(\x0c\x42\n\xbaH\x07z\x02`\x01\xd0\x01\x01R\x03valb\x06proto3')
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n*buf/validate/conformance/cases/bytes.proto\x12\x1e\x62uf.validate.conformance.cases\x1a\x1b\x62uf/validate/validate.proto\"\x1d\n\tBytesNone\x12\x10\n\x03val\x18\x01 \x01(\x0cR\x03val\"*\n\nBytesConst\x12\x1c\n\x03val\x18\x01 \x01(\x0c\x42\n\xbaH\x07z\x05\n\x03\x66ooR\x03val\",\n\x07\x42ytesIn\x12!\n\x03val\x18\x01 \x01(\x0c\x42\x0f\xbaH\x0cz\nB\x03\x62\x61rB\x03\x62\x61zR\x03val\"1\n\nBytesNotIn\x12#\n\x03val\x18\x01 \x01(\x0c\x42\x11\xbaH\x0ez\x0cJ\x04\x66izzJ\x04\x62uzzR\x03val\"%\n\x08\x42ytesLen\x12\x19\n\x03val\x18\x01 \x01(\x0c\x42\x07\xbaH\x04z\x02h\x03R\x03val\"(\n\x0b\x42ytesMinLen\x12\x19\n\x03val\x18\x01 \x01(\x0c\x42\x07\xbaH\x04z\x02\x10\x03R\x03val\"(\n\x0b\x42ytesMaxLen\x12\x19\n\x03val\x18\x01 \x01(\x0c\x42\x07\xbaH\x04z\x02\x18\x05R\x03val\"-\n\x0e\x42ytesMinMaxLen\x12\x1b\n\x03val\x18\x01 \x01(\x0c\x42\t\xbaH\x06z\x04\x10\x03\x18\x05R\x03val\"2\n\x13\x42ytesEqualMinMaxLen\x12\x1b\n\x03val\x18\x01 \x01(\x0c\x42\t\xbaH\x06z\x04\x10\x05\x18\x05R\x03val\"7\n\x0c\x42ytesPattern\x12\'\n\x03val\x18\x01 \x01(\x0c\x42\x15\xbaH\x12z\x10\"\x0e^[\\x00-\\x7F]+$R\x03val\")\n\x0b\x42ytesPrefix\x12\x1a\n\x03val\x18\x01 \x01(\x0c\x42\x08\xbaH\x05z\x03*\x01\x99R\x03val\"-\n\rBytesContains\x12\x1c\n\x03val\x18\x01 \x01(\x0c\x42\n\xbaH\x07z\x05:\x03\x62\x61rR\x03val\",\n\x0b\x42ytesSuffix\x12\x1d\n\x03val\x18\x01 \x01(\x0c\x42\x0b\xbaH\x08z\x06\x32\x04\x62uzzR\x03val\"$\n\x07\x42ytesIP\x12\x19\n\x03val\x18\x01 \x01(\x0c\x42\x07\xbaH\x04z\x02P\x01R\x03val\"\'\n\nBytesNotIP\x12\x19\n\x03val\x18\x01 \x01(\x0c\x42\x07\xbaH\x04z\x02P\x00R\x03val\"&\n\tBytesIPv4\x12\x19\n\x03val\x18\x01 \x01(\x0c\x42\x07\xbaH\x04z\x02X\x01R\x03val\")\n\x0c\x42ytesNotIPv4\x12\x19\n\x03val\x18\x01 \x01(\x0c\x42\x07\xbaH\x04z\x02X\x00R\x03val\"&\n\tBytesIPv6\x12\x19\n\x03val\x18\x01 \x01(\x0c\x42\x07\xbaH\x04z\x02`\x01R\x03val\")\n\x0c\x42ytesNotIPv6\x12\x19\n\x03val\x18\x01 \x01(\x0c\x42\x07\xbaH\x04z\x02`\x00R\x03val\"/\n\x0f\x42ytesIPv6Ignore\x12\x1c\n\x03val\x18\x01 \x01(\x0c\x42\n\xbaH\x07z\x02`\x01\xd0\x01\x01R\x03val\"*\n\x0c\x42ytesExample\x12\x1a\n\x03val\x18\x01 \x01(\x0c\x42\x08\xbaH\x05z\x03r\x01\x99R\x03valb\x06proto3')

_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
Expand Down Expand Up @@ -72,12 +72,20 @@
_globals['_BYTESSUFFIX'].fields_by_name['val']._serialized_options = b'\272H\010z\0062\004buzz'
_globals['_BYTESIP'].fields_by_name['val']._loaded_options = None
_globals['_BYTESIP'].fields_by_name['val']._serialized_options = b'\272H\004z\002P\001'
_globals['_BYTESNOTIP'].fields_by_name['val']._loaded_options = None
_globals['_BYTESNOTIP'].fields_by_name['val']._serialized_options = b'\272H\004z\002P\000'
_globals['_BYTESIPV4'].fields_by_name['val']._loaded_options = None
_globals['_BYTESIPV4'].fields_by_name['val']._serialized_options = b'\272H\004z\002X\001'
_globals['_BYTESNOTIPV4'].fields_by_name['val']._loaded_options = None
_globals['_BYTESNOTIPV4'].fields_by_name['val']._serialized_options = b'\272H\004z\002X\000'
_globals['_BYTESIPV6'].fields_by_name['val']._loaded_options = None
_globals['_BYTESIPV6'].fields_by_name['val']._serialized_options = b'\272H\004z\002`\001'
_globals['_BYTESNOTIPV6'].fields_by_name['val']._loaded_options = None
_globals['_BYTESNOTIPV6'].fields_by_name['val']._serialized_options = b'\272H\004z\002`\000'
_globals['_BYTESIPV6IGNORE'].fields_by_name['val']._loaded_options = None
_globals['_BYTESIPV6IGNORE'].fields_by_name['val']._serialized_options = b'\272H\007z\002`\001\320\001\001'
_globals['_BYTESEXAMPLE'].fields_by_name['val']._loaded_options = None
_globals['_BYTESEXAMPLE'].fields_by_name['val']._serialized_options = b'\272H\005z\003r\001\231'
_globals['_BYTESNONE']._serialized_start=107
_globals['_BYTESNONE']._serialized_end=136
_globals['_BYTESCONST']._serialized_start=138
Expand Down Expand Up @@ -106,10 +114,18 @@
_globals['_BYTESSUFFIX']._serialized_end=692
_globals['_BYTESIP']._serialized_start=694
_globals['_BYTESIP']._serialized_end=730
_globals['_BYTESIPV4']._serialized_start=732
_globals['_BYTESIPV4']._serialized_end=770
_globals['_BYTESIPV6']._serialized_start=772
_globals['_BYTESIPV6']._serialized_end=810
_globals['_BYTESIPV6IGNORE']._serialized_start=812
_globals['_BYTESIPV6IGNORE']._serialized_end=859
_globals['_BYTESNOTIP']._serialized_start=732
_globals['_BYTESNOTIP']._serialized_end=771
_globals['_BYTESIPV4']._serialized_start=773
_globals['_BYTESIPV4']._serialized_end=811
_globals['_BYTESNOTIPV4']._serialized_start=813
_globals['_BYTESNOTIPV4']._serialized_end=854
_globals['_BYTESIPV6']._serialized_start=856
_globals['_BYTESIPV6']._serialized_end=894
_globals['_BYTESNOTIPV6']._serialized_start=896
_globals['_BYTESNOTIPV6']._serialized_end=937
_globals['_BYTESIPV6IGNORE']._serialized_start=939
_globals['_BYTESIPV6IGNORE']._serialized_end=986
_globals['_BYTESEXAMPLE']._serialized_start=988
_globals['_BYTESEXAMPLE']._serialized_end=1030
# @@protoc_insertion_point(module_scope)
24 changes: 24 additions & 0 deletions gen/buf/validate/conformance/cases/bytes_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,44 @@ class BytesIP(_message.Message):
val: bytes
def __init__(self, val: _Optional[bytes] = ...) -> None: ...

class BytesNotIP(_message.Message):
__slots__ = ("val",)
VAL_FIELD_NUMBER: _ClassVar[int]
val: bytes
def __init__(self, val: _Optional[bytes] = ...) -> None: ...

class BytesIPv4(_message.Message):
__slots__ = ("val",)
VAL_FIELD_NUMBER: _ClassVar[int]
val: bytes
def __init__(self, val: _Optional[bytes] = ...) -> None: ...

class BytesNotIPv4(_message.Message):
__slots__ = ("val",)
VAL_FIELD_NUMBER: _ClassVar[int]
val: bytes
def __init__(self, val: _Optional[bytes] = ...) -> None: ...

class BytesIPv6(_message.Message):
__slots__ = ("val",)
VAL_FIELD_NUMBER: _ClassVar[int]
val: bytes
def __init__(self, val: _Optional[bytes] = ...) -> None: ...

class BytesNotIPv6(_message.Message):
__slots__ = ("val",)
VAL_FIELD_NUMBER: _ClassVar[int]
val: bytes
def __init__(self, val: _Optional[bytes] = ...) -> None: ...

class BytesIPv6Ignore(_message.Message):
__slots__ = ("val",)
VAL_FIELD_NUMBER: _ClassVar[int]
val: bytes
def __init__(self, val: _Optional[bytes] = ...) -> None: ...

class BytesExample(_message.Message):
__slots__ = ("val",)
VAL_FIELD_NUMBER: _ClassVar[int]
val: bytes
def __init__(self, val: _Optional[bytes] = ...) -> None: ...
Loading
Loading