-
Notifications
You must be signed in to change notification settings - Fork 46
feat: Null Value Support #66
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
feat: Null Value Support #66
Conversation
This improves the API here, the default value is no longer hidden in the initializer *Breaking*: Envied.path and Envied.requireEnvFile no longer accept null values as arguments
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.
Good work. I've added some comments. 🤓
packages/envied_generator/lib/src/generate_field_encrypted.dart
Outdated
Show resolved
Hide resolved
packages/envied_generator/lib/src/generate_field_encrypted.dart
Outdated
Show resolved
Hide resolved
packages/envied_generator/lib/src/generate_field_encrypted.dart
Outdated
Show resolved
Hide resolved
packages/envied_generator/lib/src/generate_field_encrypted.dart
Outdated
Show resolved
Hide resolved
packages/envied_generator/lib/src/generate_field_encrypted.dart
Outdated
Show resolved
Hide resolved
Thanks for the feedback! Please check that #66 (comment) and #66 (comment) was resolved correctly. |
Looks like it. I'll make a proper review later in the evening or tomorrow. |
`optional` vs `nullable` was confusing me, `allowOptional` and `isNullable` are much better names
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.
Added some more comments.
packages/envied_generator/lib/src/generate_field_encrypted.dart
Outdated
Show resolved
Hide resolved
packages/envied_generator/lib/src/generate_field_encrypted.dart
Outdated
Show resolved
Hide resolved
Looks good. 👍🏻 I'll leave the PR open for a few more days in case you decide to add more stuff to it. @petercinibulk care to take a look? |
Closes #25
Annotation options
Envied.allowOptionalFields
andEnviedField.optional
have been added to allow nullable fields. Optional fields are disabled by default. Below is an excerpt from the readme.Optional Environment Variables
Enable
allowOptionalFields
to allow nullable types. When a defaultvalue is not provided and the type is nullable, the generator will
assign the value to null instead of throwing an exception.
By default, optional fields are not enabled because it could be
confusing while debugging. If a field is nullable and a default
value is not provided, it will not throw an exception if it is
missing an environment variable.
For example, this could be useful if you are using an analytics service
for an open-source app, but you don't want to require users or contributors
to provide an API key if they build the app themselves.
Optional fields can also be enabled on a per-field basis by setting