chrusty / protoc-gen-jsonschema

Protobuf to JSON-Schema compiler
Apache License 2.0
496 stars 101 forks source link

validation on objects and items (repeat) #150

Open benoit-campeau opened 1 year ago

benoit-campeau commented 1 year ago

Hello, again thank you very much for providing validation.

We are seeing 2 issues right now. Probably because it is not implemented, but i dont know!

1) when we define something like this : repeated Localization localizations = 3 [(protoc.gen.jsonschema.field_options).required = true,(validate.rules).repeated.min_items = 1];

we get this : "localizations": { "items": { "$ref": "#/definitions/Localization" }, "type": "array", "description": "localized values for this title scope and type."

no minItems = 1

FYI Localization look like that message Localization { string language = 1 [(protoc.gen.jsonschema.field_options).required = true,(protoc.gen.jsonschema.field_options).min_length=2, (protoc.gen.jsonschema.field_options).pattern = "^(?!\\s*$).+"]; string value = 2 [(protoc.gen.jsonschema.field_options).required = true, (protoc.gen.jsonschema.field_options).pattern = "^(?!\\s*$).+"]; }

2) we try to use validation on items as in the doc of protoc-gen-validate. Is it possible to do something like this: repeated string value = 2 [(protoc.gen.jsonschema.field_options).required = true, (validate.rules).repeated.min_items = 1, (validate.rules).repeated.items.string.min_len = 1]; or repeated.items.string.pattern = 'regex-something' ?

Regards