Prism.Validation

The Prism.Validation is based on Prism. It allows you to use Validations based on the ValidationAttributes in your Model, ViewModel and so on.


Keywords
libary, pcl-validation, prism, uwp
License
MIT
Install
Install-Package Prism.Validation -Version 1.2.0

Documentation

Prism.Validation

The Prism.Validation is based on Prism. It allows you to use Validations based on the ValidationAttributes in your Model, ViewModel and so on. Because most of you want to share your code acroos the .NET application model (also known as App models) the Prism.Validation is shipped as PCL.

Install

Install with nuget Install-Package Prism.Validation

Useage for version 1.2.0

  1. In you PCL set your Targeting to at least .NETStandard 1.4
  2. Install Prism.Validation in your project with nuget Install-Package Prism.Validation
  3. Create your model class and inherit from ValidatableBindableBase.
  4. Decorate your properties with DataAnnotations like [StringLength(2, ErrorMessage = "Max 2 digits")]
  5. Set Binding in XAML like <TextBox Text="{Binding Name,Mode=TwoWay,ValidatesOnDataErrors=True,UpdateSourceTrigger=PropertyChanged}" />
  6. For Xamarin.Forms Projects you may check out https://www.davidbritch.com/2017/03/validating-user-input-in-xamarinforms-iv.html

Validation

Model classes are a good example which can be used to share across different platforms. Also you may want to add some basic validations into the model with DataAnnotaions.

The Prism Core Libary doesn't provide a validation implementation, so the Prism.Validation libary is filling this gap. The validation was taken over from the UWP ValidatableBindableBase with litte adjustments.

With the Prism.Validation you could share your model with DataAnnotaion between wpf, xamarin and uwp.

Screenshots

With [StringLength(2, ErrorMessage = "Max 2 digits")]

Android

alt tag

UWP

alt tag

WPF

alt tag

Changelog

1.3.0.0

  • Upgraded to Prism 7.1.0.431

1.2.0.0

  • Upgraded to Prism 7.0.0.396

1.1.0.0

1.0.0.0

Contribute

Contribute if you want.