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

Add support for enum constraints #53

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

0xC0D3D00D
Copy link

@0xC0D3D00D 0xC0D3D00D commented Feb 21, 2025

This adds support for enum constraints in jsonschema. Supported constraints:

enum Enum {
  ENUM_UNSPECIFIED = 0;
  ENUM_VAL1 = 1;
  ENUM_VAL2 = 2;
  ENUM_VAL7 = 7;
}

message E {
  Enum const_enum = 1 [(buf.validate.field).enum.const = 2];
  Enum defined_only_enum = 2 [(buf.validate.field).enum.defined_only = true];
  Enum in_enum = 3 [(buf.validate.field).enum = { in: [1, 2]}];
  Enum not_in_enum = 4 [(buf.validate.field).enum = { not_in: [0, 7]}];
  # It's also possible to have a combination of these constraints
  Enum defined_only_not_in_enum = 5 [(buf.validate.field).enum = {defined_only: true, not_in: [0]}];
}

@CLAassistant
Copy link

CLAassistant commented Feb 21, 2025

CLA assistant check
All committers have signed the CLA.

@0xC0D3D00D
Copy link
Author

@Alfus @mfridman, Are there any chances for this to get reviewed in upcoming weeks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants