diff --git a/samples/ValidationRulesTest/ValidationRulesTest/ValidationRulesTest.csproj b/samples/ValidationRulesTest/ValidationRulesTest/ValidationRulesTest.csproj index 4e0385b..b3665f3 100644 --- a/samples/ValidationRulesTest/ValidationRulesTest/ValidationRulesTest.csproj +++ b/samples/ValidationRulesTest/ValidationRulesTest/ValidationRulesTest.csproj @@ -36,6 +36,9 @@ + + MSBuild:UpdateDesignTimeXaml + MSBuild:UpdateDesignTimeXaml diff --git a/samples/ValidationRulesTest/ValidationRulesTest/ViewModels/Example6ViewModel.cs b/samples/ValidationRulesTest/ValidationRulesTest/ViewModels/Example6ViewModel.cs new file mode 100644 index 0000000..ad57b19 --- /dev/null +++ b/samples/ValidationRulesTest/ValidationRulesTest/ViewModels/Example6ViewModel.cs @@ -0,0 +1,30 @@ +using Plugin.ValidationRules; +using Plugin.ValidationRules.Extensions; +using Plugin.ValidationRules.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace ValidationRulesTest.ViewModels +{ + public class Example6ViewModel + { + public Example6ViewModel() + { + Name = Validator.Build().IsRequired("The name is required."); + Phone = Validator.Build() + .When(x => !string.IsNullOrEmpty(x)) + .Must(x => x.Length == 12, "Minimum lenght is 12."); + + Phone.ValueFormatter = new MaskFormatter("XXX-XXX-XXXX"); + } + + public Validatable Name { get; set; } + public Validatable Phone { get; set; } + + public bool Validate() + { + return Name.Validate() && Phone.Validate(); + } + } +} diff --git a/samples/ValidationRulesTest/ValidationRulesTest/Views/Example6.xaml b/samples/ValidationRulesTest/ValidationRulesTest/Views/Example6.xaml new file mode 100644 index 0000000..718c515 --- /dev/null +++ b/samples/ValidationRulesTest/ValidationRulesTest/Views/Example6.xaml @@ -0,0 +1,41 @@ + + + + + + + + + + + +