ReactiveValidation 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package ReactiveValidation --version 1.0.1
NuGet\Install-Package ReactiveValidation -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ReactiveValidation" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ReactiveValidation --version 1.0.1
#r "nuget: ReactiveValidation, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ReactiveValidation as a Cake Addin
#addin nuget:?package=ReactiveValidation&version=1.0.1

// Install ReactiveValidation as a Cake Tool
#tool nuget:?package=ReactiveValidation&version=1.0.1

Sample

public class CarViewModel : ValidatableObject
{
    public CarViewModel()
    {
        Validator = GetValidator();
    }

    private IObjectValidator GetValidator()
    {
        var builder = new ValidationBuilder<CarViewModel>();

        builder.RuleFor(vm => vm.Make).NotEmpty();
        builder.RuleFor(vm => vm.Model).NotEmpty().WithMessage("Please specify a car model");
        builder.RuleFor(vm => vm.Mileage).GreaterThan(0).When(model => model.HasMileage);
        builder.RuleFor(vm => vm.Vin).Must(BeAValidVin).WithMessage("Please specify a valid VIN");
        builder.RuleFor(vm => vm.Description).Length(10, 100);

        return builder.Build(this);
    }

    private bool BeAValidVin(string vin)
    {
        // custom vin validating logic goes here
    }

    //Properties with realization INotifyPropertyChanged goes here
}
  • Merge dictionary with default ControlTemplate for validation
  • Create default style(optional, but recommended) with AutoRefreshErrorTemplate and ErrorTemplate properties
xmlns:b="clr-namespace:ReactiveValidation.WPF.Behaviors;assembly=ReactiveValidation"
...
<ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/ReactiveValidation;component/WPF/Themes/Generic.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="TextBox" TargetType="TextBox">
        <Setter Property="b:ReactiveValidation.AutoRefreshErrorTemplate" Value="True" />
        <Setter Property="b:ReactiveValidation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
    </Style>
</ResourceDictionary>

Apply style and nothing more!

<TextBlock Grid.Row="0" Grid.Column="0" Text="Make: " />
<TextBox Grid.Row="0" Grid.Column="1" Style="{StaticResource TextBox}"
         Text="{Binding Make, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

<TextBlock Grid.Row="1" Grid.Column="0" Text="Model: " />
<TextBox Grid.Row="1" Grid.Column="1" Style="{StaticResource TextBox}"
         Text="{Binding Model, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

<TextBlock Grid.Row="2" Grid.Column="0" Text="Has mileage: " />
<CheckBox Grid.Row="2" Grid.Column="1" Margin="3"
          IsChecked="{Binding HasMileage, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

<TextBlock Grid.Row="3" Grid.Column="0" Text="Mileage: " />
<TextBox Grid.Row="3" Grid.Column="1" Style="{StaticResource TextBox}" IsEnabled="{Binding HasMileage}"
         Text="{Binding Mileage, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

<TextBlock Grid.Row="4" Grid.Column="0" Text="Vin: " />
<TextBox Grid.Row="4" Grid.Column="1" Style="{StaticResource TextBox}"
         Text="{Binding Vin, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

<TextBlock Grid.Row="5" Grid.Column="0" Text="Description: " />
<TextBox Grid.Row="5" Grid.Column="1" Style="{StaticResource TextBox}"
         Text="{Binding Description, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

More samples you can find here

Product Compatible and additional computed target framework versions.
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on ReactiveValidation:

Package Downloads
ReactiveValidation.Avalonia

A small validation library for WPF and Avalonia that uses a fluent interface and allows display messages near controls in GUI with MVVM

ReactiveValidation.Wpf

A small validation library for WPF and Avalonia that uses a fluent interface and allows display messages near controls in GUI with MVVM

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.3 929 7/15/2023
2.0.3-pre 219 3/1/2023
2.0.2 1,288 10/11/2022
2.0.1 960 7/28/2022
2.0.0-pre 198 7/19/2022
1.0.7 947 9/26/2020
1.0.5 1,660 7/10/2018
1.0.4 875 6/27/2018
1.0.3 881 6/16/2018
1.0.2 1,035 5/13/2018
1.0.1 874 5/4/2018
1.0.0 875 5/2/2018

Changelog:
* Fixed When(Expression<Func<TObject, bool>>) method
* Default TrackCultureChanged  = false
* Added PropertyChanged for Validator
* Added fallback culture - en