Xamarin Community Toolkit MultiValidationBehavior

The MultiValidationBehavior is a behavior that allows the user to combine multiple validators to validate text input depending on specified parameters. For example, an Entry control can be styled differently depending on whether a valid or an invalid text input is provided. By allowing the user to chain multiple existing validators together, it offers a high degree of customizability when it comes to validation. Additional properties handling validation are inherited from ValidationBehavior.

Syntax

<Entry>
    <Entry.Behaviors>
        <xct:MultiValidationBehavior
            x:Name="MultiValidation"
            InvalidStyle="{StaticResource InvalidEntryStyle}">

            <xct:NumericValidationBehavior
                xct:MultiValidationBehavior.Error="NaN"
            />
            <xct:NumericValidationBehavior
                MinimumValue="-10"
                xct:MultiValidationBehavior.Error="Min: -10"
            />
            <xct:NumericValidationBehavior
                MaximumValue="5"
                xct:MultiValidationBehavior.Error="Max: 5"
            />

        </xct:MultiValidationBehavior>
    </Entry.Behaviors>
</Entry>

Properties

Property Type Description
Error object An attached property on nested validators setting the error message for that validator.
Errors List<object> Holds the errors from all of the nested invalid validators.

Sample

You can see this in action in the Xamarin Community Toolkit Sample App.

API