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

Make ApiSecret a required property #40

Merged
merged 1 commit into from
Sep 26, 2023
Merged

Conversation

Tyrrrz
Copy link
Contributor

@Tyrrrz Tyrrrz commented Sep 25, 2023

If a property is not nullable and does not have a default value, then it must be marked as required. That way, if the user doesn't set it, it becomes a compile-time error and not a run-time error.

@abergs
Copy link
Member

abergs commented Sep 25, 2023

@Tyrrrz I don't have any feedback of value here - I know way to little about polyfilling. I trust you that this works.

@abergs abergs removed their request for review September 25, 2023 16:34
@Tyrrrz
Copy link
Contributor Author

Tyrrrz commented Sep 25, 2023

@justindbaur do you have any thoughts? 🙂

@justindbaur
Copy link
Member

We are validating that ApiSecret is non-null through: https://github.com/passwordless/passwordless-dotnet/blob/3d841dbe021e2d30382b0c0253017618b623b6f0/src/Passwordless/ServiceCollectionExtensions.cs#L16 but this doesn't happen until first construction of IOptions<PasswordlessOptions>.

I'm guessing Activator.CreateInstance<PasswordlessOptions>() doesn't respect the required?

@Tyrrrz
Copy link
Contributor Author

Tyrrrz commented Sep 25, 2023

Yeah, it's validating at run-time, this adds compile-time validation. It won't help in the builder overload but will help in those where PasswordlessOptions are provided directly, including in internal code.

@Tyrrrz Tyrrrz merged commit 89fd3e5 into main Sep 26, 2023
2 checks passed
@Tyrrrz Tyrrrz deleted the make-required-props-required branch September 26, 2023 09:43
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.

3 participants