StringPropertyValidator - Parametric/Simple.Validation GitHub Wiki

Used to validate string properties. This validator is most easily used through the Fluent Properties API.

            yield return Properties<Address>.
                For(a => a.Line1)
                .Length(0, 50)
                .Required()
                .Message("Address Line 1 is required.");

It's supported methods are:

  • DoNotIgnoreWhiteSpace() - Whitespace is ignored by the Required() and Length() functions.
  • If() - specifies a condition under which the validator will be executed.
  • IgnoreWhiteSpace() - Whitespace is counted by the Required() and Length() functions.
  • IsFalse(predicate) - requires that the specified predicate function return false.
  • IsTrue() - requires that the specified predicate function return true;
  • Length() - requires that the length of the string be in range.
  • Matches() - tests the string against a regular expression.
  • Message() - Specifies the message to be returned if the validation fails.
  • NotRequired() - The property is not required.
  • Required() - The property is required.
  • Severity() - Specifies the severity of the ValidationResult if the validator fails.
  • Type() - Specifies the type of the ValidationResult if the validator fails.
⚠️ **GitHub.com Fallback** ⚠️