Skip to content

Instantly share code, notes, and snippets.

@jafaircl
Last active March 20, 2024 14:30
Show Gist options
  • Save jafaircl/b41d5e3a6f519815346433ec88f6aa8a to your computer and use it in GitHub Desktop.
Save jafaircl/b41d5e3a6f519815346433ec88f6aa8a to your computer and use it in GitHub Desktop.
{
"$id": "buf.validate.AnyRules.schema.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": false,
"description": "AnyRules describe constraints applied exclusively to the `google.protobuf.Any` well-known type.",
"properties": {
"in": {
"description": "`in` requires the field's `type_url` to be equal to one of the\nspecified values. If it doesn't match any of the specified values, an error\nmessage is generated.\n\n```proto\nmessage MyAny {\n // The `value` field must have a `type_url` equal to one of the specified values.\n google.protobuf.Any value = 1 [(buf.validate.field).any.in = [\"type.googleapis.com/MyType1\", \"type.googleapis.com/MyType2\"]];\n}\n```",
"items": {
"type": "string"
},
"type": "array"
},
"not_in": {
"description": "requires the field's type_url to be not equal to any of the specified values. If it matches any of the specified values, an error message is generated.\n\n```proto\nmessage MyAny {\n // The field `value` must not have a `type_url` equal to any of the specified values.\n google.protobuf.Any value = 1 [(buf.validate.field).any.not_in = [\"type.googleapis.com/ForbiddenType1\", \"type.googleapis.com/ForbiddenType2\"]];\n}\n```",
"items": {
"type": "string"
},
"type": "array"
}
},
"title": "Any Rules",
"type": "object"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment