-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add null option and rewrite README #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Restructure README to show value upfront with before/after comparison, add behavior table for enforce/default/null interaction, and improve overall readability while maintaining technical accuracy.
- Remove duplicate 'Parameterized Types' section (already covered in 'Type Parameters') - Remove duplicate 'Custom Types' section (already covered in 'Opaque Types') - Fix @moduledoc placement in Documentation example (should be at module level) - Rename test to accurately describe what it tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- 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
1d91b95 to
0835f60
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
test/null_option_test.exs
Outdated
| field :email, String.t(), enforce: true | ||
| end | ||
| after | ||
| # Struct can be created with nil for nullable fields |
Copilot
AI
Dec 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment could be misleading. The test demonstrates that fields can be nil at runtime even with null: false (line 47), not just "nullable fields". Consider revising to clarify that the null option only affects the type specification, not runtime behavior. For example: "Fields can hold nil at runtime regardless of null option".
| # Struct can be created with nil for nullable fields | |
| # Struct fields can be nil at runtime regardless of null option in the type spec |
Summary
nulloption for field types to control nullability explicitlyChanges
New
nulloptionFields can now use
null: falseto preventnilfrom being added to their type, ornull: true(default) to allow it. This is useful for database records where some fields are always present (likeid,inserted_at).The option can also be set at the module level:
README rewrite
Changelog