nullable reference types support
See original GitHub issueSome thoughts:
- C# 8 introduces nullable reference types, and therefore non-nullable reference types
- FluentValidation API could then be enhanced and DRY’d up a bit to support even more fluent syntax
When
builder syntax today is reflexive to the parent, not the property.
RuleFor(s => s.NullableReferenceProperty)
.NotEmpty()
// WhenNotNull wouldnt be possible if NON-NullableReferenceProperty
.WhenNotNull(); // more succinct than: .When(s => s.NullableReferenceProperty.HasValue);
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Nullable reference types
Nullable reference types refers to a group of features enabled in a nullable aware context that minimize the likelihood that your code causes ......
Read more >Nullable reference types - C# reference
Nullable reference types aren't new class types, but rather annotations on existing reference types. The compiler uses those annotations to help ...
Read more >Digging Into Nullable Reference Types in C#
Enabling Nullable Reference Types · PropertyGroup · OutputType · OutputType · TargetFramework · TargetFramework · ImplicitUsings · ImplicitUsings ...
Read more >Nullable Reference types in C# – Best practices
In this tutorial, I look at the state of the Nullable Reference Types feature in C#, one year after its initial release.
Read more >What are nullable reference types in C# 8.0?
As the name suggests, nullable reference types may be null . When variables may be null , the compiler enforces specific rules to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s trivial to implement a
WhenNotNull
method today which works against both reference types and nullable value types:I’m not following how c# 8’s nullable reference types would make any difference to this?
Yes I’ve read that before, I do understand nullable reference types and their impact. What I’m not understanding is what you expect FluentValidation to be doing differently. Do you have a specific example of how you’d expect the behaviour to change?
Yes most methods in the public API are just wrappers around Configure, which provides access to the underlying model.