Skip to content

Commit

Permalink
docs: add documentation for @nullable support.
Browse files Browse the repository at this point in the history
  • Loading branch information
credmond-git committed Jul 3, 2024
1 parent 28762d7 commit 655226a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,13 @@ Treat missing discretionary values (optional, fields with defaults, fields with
- If this is `true`, if a field is missing and would have had a default, it will fail and throw an exception.


### `@Nullable` annotations

If a field or method is annotated with a `@Nullable` annotation, it will treat a missing value as a discretionary value. So as long as `treatMissingDiscretionaryValuesAsErrors` is not enabled, `@Nullable` fields will allow null values without throwing errors.

There are multiple `@Nullable` annotations and for this to work the annotations must use `@Retention(RetentionPolicy.RUNTIME)` so the annotation is available at runtime for Gestalt.
One good library to use is `jakarta.annotation:jakarta.annotation-api` that has a `@Nullable` with `@Retention(RetentionPolicy.RUNTIME)`.

#### Examples of required and discretionary fields.

Here are some examples of required and discretionary fields and which setting can control if they are treated as errors or allowed.
Expand Down

0 comments on commit 655226a

Please sign in to comment.