Package with multiple field validations for Xamarin.Forms.
Easily validate numbers, texts and implement masks.
NuGet
Name | Info |
---|---|
Xamarin.Forms.BehaviorValidationPack | |
Xamarin.Forms.BehaviorValidationPack.XFMaterial |
Platform Support
Xamarin.Forms.BehaviorValidationPack is a .NET Standard 2.0 library.Its only dependency is the Xamarin.Forms
Does not require additional configuration. Just install the package in the shared project and use.
You just need to add the reference in your xaml file.
xmlns:behaviorPack="clr-namespace:Xamarin.Forms.BehaviorValidationPack;assembly=Xamarin.Forms.BehaviorValidationPack"
Behavior
<Label Text="Date" FontSize="Small" />
<DatePicker >
<DatePicker.Behaviors>
<behaviorPack:DateValidationBehavior/>
<behaviorPack:MaskedBehavior Mask="XX/XX/XXXX" />
</DatePicker.Behaviors>
</DatePicker>
<Label Text="Age" FontSize="Small" />
<Entry Placeholder="Age" FontSize="Small">
<Entry.Behaviors>
<behaviorPack:MaxLengthValidationBehavior MaxLength="2"/>
<behaviorPack:NumberValidationBehavior/>
</Entry.Behaviors>
</Entry>
Behavior for XF-Material-Library
<material:MaterialLabel Text="Date" FontSize="Small" />
<DatePicker >
<DatePicker.Behaviors>
<behaviorPack:DateValidationBehavior/>
<behaviorPack:MaskedBehavior Mask="XX/XX/XXXX" />
</DatePicker.Behaviors>
</DatePicker>
<material:MaterialLabel Text="Age" FontSize="Small" />
<material:MaterialTextField Placeholder="Age" FontSize="Small">
<material:MaterialTextField.Behaviors>
<behaviorPack:MaxLengthValidationBehavior MaxLength="2"/>
<behaviorPack:NumberValidationBehavior/>
</material:MaterialTextField.Behaviors>
</material:MaterialTextField>
Available Behaviors
Global Validators
Brazilians Validators
Masks
Based on MaskedBehavior by Adam Pedley (https://xamarinhelp.com/masked-entry-in-xamarin-forms/).
<behaviorPack:MaskedBehavior Mask="XX/XX/XXXX" />
The complete example can be downloaded here: https://github.com/TBertuzzi/Xamarin.Forms.BehaviorValidationPack/tree/master/BehaviorsPackSample