Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

all_fields_required with optional #148

Open
k-jay-c opened this issue Apr 12, 2023 · 5 comments
Open

all_fields_required with optional #148

k-jay-c opened this issue Apr 12, 2023 · 5 comments
Assignees

Comments

@k-jay-c
Copy link

k-jay-c commented Apr 12, 2023

Wondering if it's possible to update so that you treat all fields as required, unless it's explicitly has optional in the proto? Currently, if you set the flag all_fields_required, it will treat even fields which are marked as optional explicitly as required,.

@chrusty
Copy link
Owner

chrusty commented Apr 20, 2023

Hi @k-jay-c, yeah OK I see what you're saying here. Let me take a look and figure out how easy this would be to implement.

@chrusty chrusty self-assigned this Apr 20, 2023
@chrusty
Copy link
Owner

chrusty commented Apr 20, 2023

Alright, one thing to mention is that this would only ever apply to Proto2 (as with Proto3 we have to assume the defaults, being every field is optional).

@k-jay-c
Copy link
Author

k-jay-c commented Apr 21, 2023

Hi @chrusty,

I believe this logic can apply to Proto3 as well. By applying the flag "all_fields_required", we're overwriting the default proto3 behaviour. This enhancement allows for more fine grained control to define which fields to treat as required. Alternative could be a new flag - all_non_optional_fields_required?

Thanks,
Jay.

@ZeeD
Copy link

ZeeD commented May 17, 2023

FWIW I would find very useful to be able to mark as required only the "non-optional" fields. On proto3 they have re-added optional too, and the rationale is a bit complex to follow, but it's available here.
In our project we are basically following what they call Explicit presence discipline but at the end we try to use the .proto files also to build our datamodel schema, and we assume that if a field does not have the "optional" keyword should be treated as required.

@ZeeD
Copy link

ZeeD commented Jul 12, 2023

@chrusty sorry to bother, but are there any news about this issue?

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

No branches or pull requests

3 participants