OptionalValidator

public struct OptionalValidator : Validator

The OptionalValidator has two stages of conditions. First the primaryCondition is checked. If it is met, then the subsequent condition are checked for violations. If the primaryCondition is not met, then no violation is returned.

As an example, say you only want violations to show if there is text in the field, but otherwise ignore it as it is an optional field in a form. In this case you would use a PresentCondition as the primaryCondition and your subsequent validation requirements as the conditions.