PropertyValidator - Parametric/Simple.Validation GitHub Wiki

The hub of the Fluent Properties API.

If() is evaluated first. If the condition in If() is met, then Required() is evaluated. If Required() is satisified and the value is not null, then all calls to Assert() are evaluated. If any Assertions are false, validation fails.

Sample:

            yield return Properties<Employee>
                .For(e => e.Age)
                .MinValue(18)
                .MaxValue(35)
                ;

Supported methods are:

  • Assert() - Adds a condition that must be satisfied for the property to be valid.
  • If() - specifies a condition under which the validator will be executed.
  • Message() - Specifies the message to be returned if the validation fails.
  • Required() - specifies that the property value must be specified.
  • Severity() - Specifies the severity of the ValidationResult if the validator fails.
  • Type() - Specifies the type of the ValidationResult if the validator fails.

IComarable property extensions

  • MinValue() - Specifies the lower end of the valid range.
  • MaxValue() - Specifies the upper end of the valid range.
  • GreaterThan() - Same as MinValue().LowerExclusive();
  • GreaterThanOrEqualTo() - Same as MinValue().LowerInclusive();
  • LessThan() - Same as MaxValue().UpperExclusive();
  • LessThanOrEqualTo() - MaxValue().UpperInclusive();
  • LowerExclusive() - Specifies that values equal the lower bound are not valid.
  • LowerInclusive() - Specifies that values equal to the lower bound are valid.
  • UpperExclusive() - Specifies that values equal to the upper bound are not valid.
  • UpperInclusive() - Specifies that values equal to the upper bound are valid.

Boolean property extensions

  • IsTrue() - Specifies that the property value is true.
  • IsFalse() - Specifies that the property value is false.
⚠️ **GitHub.com Fallback** ⚠️