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
##Use
- Use in your PCL Profile
Profile7
(Set in your .csproj<TargetFrameworkProfile>Profile7</TargetFrameworkProfile>
) - Install Prism.Validation in your project with nuget
Install-Package Prism.Validation
- Create your model class and inherit from
ValidatableBindableBase
. - Decorate your properties with DataAnnotations like
[StringLength(2, ErrorMessage = "Max 2 digits")]
- Set Binding in XAML like
<TextBox Text="{Binding Name,Mode=TwoWay,ValidatesOnDataErrors=True,UpdateSourceTrigger=PropertyChanged}" />
##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 (Related Issue on Prism), 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.
##Changelog
###1.1.0.0
- Replaced Portable Data Annotations with System.ComponentModel.Annotations
- Changed Prism.Validation PCL to portable45-net45+win8
- #4 Fixed by using System.ComponentModel.Annotations
- #5 Upgrade packages to Prism 6.2
- #3 Rename Prism.Extensions to Prism.Validation enhancement
###1.0.0.0
- Init (The validation was taken over from the UWP ValidatableBindableBase with litte adjustments.)
- Used Portable Data Annotations
##Contribute Contribute if you want.