Comments (10)
Hi xigolle,
At this time the thought is to remove that capability. The value add did not seem worth the complexity added to the APIs and possible feature creep of validating things outside of arguments.
If you could help explain your use case we can suggest solutions or reconsider these ideas.
Thanks!
from ensure.that.
Hi ndrwrbgs,
Well now when ensureThat throws an error if something is null it is just a generic message like value cannot be null.
But it would be nice if we could set a more custom message so we can inform the user better on what is happening.
from ensure.that.
Some options comes to my mind (note, not saying anything is correct)
- We keep the
Ensure.That
(sigh... never ending story) - We see this library as a guard clause lib for enforcing contracts, not a validation for end user.... and then skip support for custom messages
- We add an optional argument
(param, opts) => opts.CustomMessage($"This value {param} is no good")
from ensure.that.
To be honest I really like the last idea. That way you can still use the lib as a guard clause but leave it open for additional messages.
from ensure.that.
Decision is to add something like:
(param, opts) => opts.CustomMessage($"This value {param} is no good")
Note. It should be possible to (later on) extend this with something like:
(param, opts) => opts.CustomException(new FooException())
from ensure.that.
What’s the expected type of opts here?
from ensure.that.
I will call it EnsureOptions
from ensure.that.
from ensure.that.
Nope. To contain optional customizations of the exception or message:
EnsureArg.IsTrue(true, "myParam", o => o.WithMessage("asdf"));
or
EnsureArg.IsTrue(true, "myParam", o => o.WithException(new FooException("Schnitzel!"));
The latter takes precedence.
from ensure.that.
Something like this: 1b6411c
Will probably add WithExtraMessage
to ease migration from obsolete Ensure.That
and perhaps change for Funcs
.
from ensure.that.
Related Issues (20)
- Bring back netstandard2.0 target
- Breaking change from 8.1.2 to 8.2.0 HOT 4
- EnsureArg.IsNotNull without class requirement HOT 7
- Add the ability to check that a string is made up of a certain type of character(s) HOT 4
- Please add TimeSpan Lt, Gt, etc
- StringParam.* SizeIs and HasLengthBetween are congruent methods, but have inconsistent naming style HOT 2
- Ensure.That(enumerable).HasItems() HOT 3
- Return Guid from string.IsGuid
- EnsureArg.IsNotNull for nullable value type HOT 9
- Default exception factory takes account of CustomExceptionFactory for ArgumentNullException only HOT 1
- Drop support for .NET 4.5.1 and .NET Standard 1.1 HOT 5
- CollectionArg methods disregard optsFn for null checks HOT 6
- Use Scope instead of argument passing of Options HOT 5
- Digitally signed assemblies HOT 8
- No more OPTS
- Fix S4144 in AnyArg
- Enable analyzers
- Chaining clauses HOT 6
- Change InvokerParameterNameAttribute to CallerMemberNameAttribute HOT 3
- Use CallerArgumentExpression attribute to capture parameter name HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ensure.that.