StringPropertyValidator

crmckenzie edited this page Apr 26, 2012 · 3 revisions

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.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.