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

Custom message is ignored in Guard.Against.NullOrWhiteSpace #150

Closed
VolkmarR opened this issue Nov 3, 2021 · 2 comments
Closed

Custom message is ignored in Guard.Against.NullOrWhiteSpace #150

VolkmarR opened this issue Nov 3, 2021 · 2 comments

Comments

@VolkmarR
Copy link

VolkmarR commented Nov 3, 2021

.NET SDK Version: 5.0

Execute this code

var dummy = "";
Guard.Against.NullOrWhiteSpace(dummy, nameof(dummy), "Custom message for Dummy not null or whitespace");

The message of the exception is "Required input dummy was empty. (Parameter 'dummy')" instead of the specified message "Custom message for Dummy not null or whitespace".

To fix this, the code line

Guard.Against.NullOrEmpty(input, parameterName);

probably needs to be changed to

Guard.Against.NullOrEmpty(input, parameterName, message); 

There are other instances of this problem.

@VolkmarR
Copy link
Author

VolkmarR commented Nov 3, 2021

I could make a PR to fix this issue, if you like.

@ardalis
Copy link
Owner

ardalis commented Nov 3, 2021

That would be great, thanks!

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

No branches or pull requests

2 participants