Boolean Functions


True

Ensures the boolean value being validated is true.

Methods
True()
True<T>(Expression<Func<T, bool>> selector)
Broken Rule

Value must be true.

Example Usage

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 });

False

Ensures the boolean value being validated is false.

Methods
False()
False<T>(Expression<Func<T, bool>> selector)
Broken Rule

Value must be false.

Example Usage

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 });