Ensures the boolean value being validated is true.
Value must be true.
Using type instance.
var validator = new ValidatorBuilder<bool>()
.True()
.Build();
var result = validator.Validate(1 == 1);
Using selector expression.
var validator = new ValidatorBuilder<Employee>()
.True(e => e.Active)
.Build();
var result = validator.Validate(new Employee { Active = false });
Using For function.
var validator = new ValidatorBuilder<Employee>()
.For(e => e.Active, v => v.True())
.Build();
var result = validator.Validate(new Employee { Active = true });
Ensures the boolean value being validated is false.
Value must be false.
Using type instance.
var validator = new ValidatorBuilder<bool>()
.False()
.Build();
var result = validator.Validate(1 == 1);
Using selector expression.
var validator = new ValidatorBuilder<Employee>()
.False(e => e.Active)
.Build();
var result = validator.Validate(new Employee { Active = false });
Using For function.
var validator = new ValidatorBuilder<Employee>()
.For(e => e.Active, v => v.False())
.Build();
var result = validator.Validate(new Employee { Active = true });