Feature | Is supported |
---|---|
Null safe | |
Validation | |
EF Core | |
EF 6 |
Info
Join Specifications as logical AND.
Usage (A && B)
Specification
.True()
.And()
.True()
.IsSatisfiedBy(true); // true
Specification
.True()
.And()
.False()
.IsSatisfiedBy(true); // false
Specification
.False()
.And()
.False()
.IsSatisfiedBy(true); // false
Multiple composition ways
Below all examples, generate the same result.
Specification
.NotNull<string>()
.And()
.NotEmail();
Specification
.NotNull<string>()
.And(Specification
.Email());
// Create EmailSpecification with parameter-less constructor
Specification
.NotNull<string>()
.And<string, EmailSpecification>();
Grouping
A && (B || C)
Specification
.NotEmpty<string>()
.And(Specification
.Contains("lorem")
.Or()
.Contains("ipsum"));
(A || B) && C
Specification
.And(Specification
.Contains("lorem")
.Or()
.Contains("ipsum"),
Specification
.NotEmpty<string>());
(A || B) && (C || D)
Specification
.And(Specification
.Length<string>(3)
.Or()
.MinLength(10),
Specification
.Contains("lorem")
.Or()
.Contains("ipsum"));
And Not (A && !B)
Specification
.True()
.AndNot()
.True()
.IsSatisfiedBy(true); // false
Specification
.True()
.AndNot()
.False()
.IsSatisfiedBy(true); // true
Specification
.False()
.AndNot()
.False()
.IsSatisfiedBy(true); // false
Grouping
A && !(B || C)
Specification
.NotEmpty<string>()
.AndNot(Specification
.Contains("lorem")
.Or()
.Contains("ipsum"));
(A || B) && !C
Specification
.AndNot(Specification
.Contains("lorem")
.Or()
.Contains("ipsum"),
Specification
.NotEmpty<string>());
(A || B) && !(C || D)
Specification
.AndNot(Specification
.Length<string>(3)
.Or()
.MinLength(10),
Specification
.Contains("lorem")
.Or()
.Contains("ipsum"));