Skip to main content
net10.0net11.0net9.0

StrongOf helps to implement primitives as a strong type that represents a domain object (e.g. UserId, EmailAddress, etc.). It is a simple class that wraps a value and provides a few helper methods to make it easier to work with. In contrast to other approaches, StrongOf is above all simple and performant - and not over-engineered.

Published
Oct 4, 2026
1mo ago
Total Downloads
11.3K
11,255

Install

dotnet add package StrongOf.FluentValidation --version 3.1.2
ProductVersions
.NET
net10.0net11.0net9.0

README

StrongOf.FluentValidation

FluentValidation extensions for StrongOf types.

NativeAOT boundary

This extension does not promise NativeAOT compatibility for its FluentValidation dependency. Its source is checked with the AOT and trimming analyzers, but the assembly is not marked IsAotCompatible and the repository's native smoke test does not cover FluentValidation.

For validation without that dependency, use IValidatable, StrongValidation.TryCreate or StrongValidation.Require from the AOT-compatible core package. Applications using FluentValidation must publish and test their complete validator configuration and dependencies separately.

Why Not NotNull()?

For strong types, NotNull() only checks the object reference. StrongOf provides HasValue() which covers both nullability and empty values:

public sealed class UserValidator : AbstractValidator<User>
{
    public UserValidator()
    {
        RuleFor(x => x.UserId)
            .HasValue()            // not NotNull()
            .WithMessage("User ID is required.");

        RuleFor(x => x.Email)
            .HasValue()
            .WithMessage("Email is required.");
    }
}

Available Extensions

Common (all strong types)

Method Applies To Description
HasValue() All strong types Not null and, for string types, not empty/whitespace
IsEqualTo(Func<T,TStrong?>, string) Type-specific validators that support comparisons Must equal another property; pass accessor and member name
IsNotEqualTo(Func<T,TStrong?>, string) Type-specific validators that support comparisons Must not equal another property; pass accessor and member name

StrongString

Method Description
HasMinimumLength(int) Minimum character length
HasMaximumLength(int) Maximum character length
IsRegexMatch(Regex) Must match a regular expression
AllowedChars(ICollection<char>, string) Must only contain characters from the allowed set

StrongInt32 / StrongInt64

Method Description
HasMinimum(int/long) Value must be ≥ min
HasMaximum(int/long) Value must be ≤ max
HasRange(int/long, int/long) Value must be within [min, max]

StrongDateTime / StrongDateTimeOffset

Method Description
HasMinimum(DateTime/DateTimeOffset) Value must be ≥ min
HasMaximum(DateTime/DateTimeOffset) Value must be ≤ max
HasRange(DateTime/DateTimeOffset, ...) Value must be within [min, max]

Installation

dotnet add package StrongOf.FluentValidation

GitHub

See https://github.com/BenjaminAbt/StrongOf

Changes from Previous Version

v3.0.35v3.1.2
Removed Frameworks
net8.0
Removed Dependencies
StrongOf(net8.0)

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

Compatibility metadata lists 3 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.