Skip to content
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!: implement default handling for fields #105

Merged
merged 2 commits into from
Jul 3, 2024

Conversation

maxveldink
Copy link
Owner

Defaults in Structs didn't work at all and failed the required field validations. This change makes these work by significantly changing the underlying Field class.

  • We now unwrap nilable types in Fields, storing the non-nilable component in the type ivar and setting the field to optional.
  • You can now indicate if you want something optional through the Field initializer instead of indicating if it's required. This allows you to pass a non-nilable type but benefit from optional validations.
  • We now allow you to set a default to be used during coercion and validation if nil is supplied to an optional field.
  • Refactored the StructCoercer to recursively call deserialize from a hash (sorry @antoinesaliba 😓 )

@maxveldink maxveldink merged commit 054d59f into main Jul 3, 2024
5 checks passed
@maxveldink maxveldink deleted the implement-default-handling branch July 3, 2024 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant