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: Document required + default as optional #1454

Merged
merged 4 commits into from
Jul 31, 2023

Conversation

WoH
Copy link
Collaborator

@WoH WoH commented Jul 22, 2023

Required + default does not make sense – if a value is required, the client must always send it, and the default value is never used.

For user convenience however, it makes sense in TypeScript to declare non-optional + default, since the validation layer fills defaults on required properties.

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Have you written unit tests?
  • Have you written unit tests that cover the negative cases (i.e.: if bad data is submitted, does the library respond properly)?
  • This PR is associated with an existing issue?

Closing issues

Put closes #XXXX (where XXXX is the issue number) in your comment to auto-close the issue that your PR fixes.

If this is a new feature submission:

  • Has the issue had a maintainer respond to the issue and clarify that the feature is something that aligns with the goals and philosophy of the project?

Potential Problems With The Approach

Should be considered breaking. Even though it should only reflect the actual behavior of the validation more accurately.

WoH added 3 commits July 22, 2023 13:25
Required + default does not make sense – if a value is required, the client must always send it,
and the default value is never used.

For user convenience however, it makes sense in TypeScript to declare
non-optional + default, since the validation layer fills defaults on
required properties.
@WoH WoH marked this pull request as ready for review July 30, 2023 16:52
@WoH WoH merged commit e3d3f50 into master Jul 31, 2023
54 checks passed
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.

None yet

1 participant