Plugin.ValidationRules 1.2 is here!

Table of Contents

This time I want to introduce the latest stable version of Plugin.ValidationRules 1.2. This major release offers many quality improvements and new features added, including ValueChanged ValidateCommand , ValueFormatter, among other things.

I want to extend a great thanks to all the people who use this plugin, and for the good feedback, it has received. You guys are amazing!

Luis Matos

In the last few days I’ve been updating the libraries and the Visual Studio extensions that you create a time ago, this time we’ll focus on Plugin.ValidationRules.

¡Let’s do this!

Upgrade to 1.2

I’ve updated some of the examples and added a few more so you can test or see more or less how the new features work. There really isn’t any breaking changes, if you upgrade now, everything should keep working the same as before.

New features

Validatable Objects

  • Now take ValidationRules by the constructor.
  • Now implement ValueChanged event.
  • Now implement ValidateCommand command – by default, it is attached to the method Validate() of your property.
  • Now implement ValueFormatter to format user input without having to write XAML extensions.
public class MyViewModel
        public MyViewModel()
            Phone = new Validatable<string>(new IsNotNullOrEmptyRule());
            Phone.ValueChanged += (o, e) => { /* Do something here */ };
            Phone.ValueFormatter = new MaskFormatter("X (XXX) XXX-XXXX");
        public Validatable<string> Phone { get; set; }
       <Entry Text="{Binding Phone.Value, Mode=TwoWay}">
                <bx:EventToCommandBehavior Command="{Binding Phone.ValidateCommand}" EventName="Unfocused" />

Formatters by default

You can now format your properties from your ViewModels in an easy and simple way. Below is the list of the default Formatters in this release:

  • BoolNegationFormatter
  • MaskFormatter
  • StringCaseFormatter
  • StringNumericFormatter

ValidationRules by default

That’s right, a lot of people asked for it for a long time. Below is the list of default rules in this release:

  • CrediCardRule
  • EmailRule
  • EmptyRule
  • EnumRule
  • EqualRule
  • GreaterThanOrEqualRule
  • InclusiveBetweenRule
  • LenghtRule
  • LessThanOrEqualRule
  • LessThanRule
  • NotEmptyRule
  • NotEqualRule
  • NotNullRule
  • RegularExpressionRule


In the #DotNetConf past you asked me about mappers, and I replied that you had to do it manually, BUT NO MORE!

  • You can now use the IMapperValidator interface and create your own mapper in your model validator (ValidatorModel).
  • You can now use the extension method MapValidator<Model, Validator>() to auto map your model validators.
public class UserValidator : IMapperValidator<User>

        public User Map()
            // Simple Manual Mapper
            var manualMapperUser = new User
                Name = this.Name.Value,
                LastName = this.LastName.Value,
                Email = this.Email.Value

            return manualMapperUser;

/* OR */
private void MappingTestMethod()
       // Extension Mapper with simple Model
       var extMapperUser = User.MapValidator<User, UserValidator>();

⚠ Note: In the speed tests of the mapper we had the following results:

Manual Mapper: 0.002 sec.
Extension Mapper: 0.013 sec.

The users will not notice the difference. The speed or performance will depend on your models and it is good to keep this tip in mind.

Resources, Documentation, Examples and Videos

See the release changes notes for full details on what’s new in the release. You can also review the initial and complementary documentation that is very useful.

I don’t think new documentation is needed, as the new features only support what had already been proposed.

The Xamarin.Forms sample can be reviewed from today and is updated with the Plugin.ValidationRules 1.2 version.



The truth is that I am very happy with this update, and it is that once you start using the plugin it is very difficult for you to change it or try to use something else.

Update the plugin to 1.2 through NuGet Package Manager. Let me know how you’re doing! And if you have any problems, please create an Issue or write to me on twitter @luismatosluna.

Share this content!