You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Clarify that null: true is the default behavior
- Condense option tables from 8 rows to 4 using "-" for irrelevant values
- Use consistent column order (default, enforce, null) across tables
- Improve wording for "Providing Defaults" section
Copy file name to clipboardExpand all lines: lib/typed_structor.ex
+6-9Lines changed: 6 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ defmodule TypedStructor do
27
27
28
28
* `:module` - if provided, a new submodule will be created with the struct.
29
29
* `:enforce` - if `true`, the struct will enforce the keys, see `field/3` options for more information.
30
-
* `:null` - if `true`, all fields without a default value and not enforced will have `nil` added to their type.
30
+
* `:null` - if `true` (default), fields without a default value and not enforced will have `nil` added to their type. If `false`, prevents `nil` from being added.
31
31
* `:definer` - the definer module to use to define the struct, record or exception. Defaults to `:defstruct`. It also accepts a macro that receives the definition struct and returns the AST. See definer section below.
32
32
* `:type_kind` - the kind of type to use for the struct. Defaults to `type`, can be `opaque` or `typep`.
33
33
* `:type_name` - the name of the type to use for the struct. Defaults to `t`.
@@ -238,19 +238,16 @@ defmodule TypedStructor do
238
238
* `:default` - sets the default value for the field
239
239
* `:enforce` - if set to `true`, enforces the field, and makes its type
240
240
non-nullable if `:default` is not set
241
-
* `:null` - if set to `true`, makes the field type nullable
242
-
if `:default` is not set and `:enforce` is not set
241
+
* `:null` - when set to `true` (the default), allows `nil` to be added to the
242
+
field type when `:default` is not set and `:enforce` is not set; when set
243
+
to `false`, prevents `nil` from being added in that case
243
244
244
245
> ### How `:default`, `:enforce` and `:null` affect `type` and `@enforce_keys` {: .tip}
0 commit comments