flipkart-incubator / Krystal

Apache License 2.0
7 stars 14 forks source link

#ExplicitMandatory Make inputs and dependencies mandatory only if @Mandatory annotation is set on the facet. #265

Open RamAnvesh opened 2 months ago

RamAnvesh commented 2 months ago

Mandatory Inputs and Dependencies are dangerous. They can cause who vajrams to fail (that is the meaning of mandatory). Also adding a new mandatory input breaks backward compatibility. Today when we add a input/dependency to a vajram, it assumed as mandatory by default unless the developer marks the type of the facet field as Optional<T>. This is dangerous. All facets must be optional unless the developer deliberately marks it as mandatory.

To support, remove support for Optional<> in facets, and provide a @Mandatory annotation which MUST be added to mandatory facets. If this annotation is missing, then the facet is assumed to be Optional