Skip to content

Commit

Permalink
Version 2.0.0 BREAKING CHANGES:
Browse files Browse the repository at this point in the history
- Changed component namespace from FluentValidation.FluentValidator to Microsoft.AspNetCore.Components.Forms.FluentValidator to solve namespace-related issues when used in projects with Accelist.* namespace!
- Set ServiceScope property in component to private. (Accidentally made public!)
  • Loading branch information
ryanelian committed Feb 5, 2020
1 parent be520a4 commit f297bdf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ Validator parameter may also be passed directly to the component to inline the A
<RepositoryUrl>https://github.com/ryanelian/FluentValidation.Blazor</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.4.0</Version>
<Version>2.0.0</Version>
<PackageIcon>icon.png</PackageIcon>
<PackageReleaseNotes>Version 2.0.0 BREAKING CHANGES:
- Changed component namespace from FluentValidation.FluentValidator to Microsoft.AspNetCore.Components.Forms.FluentValidator to solve namespace-related issues when used in projects with Accelist.* namespace!
- Set ServiceScope property in component to private. (Accidentally made public!)</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand Down
5 changes: 2 additions & 3 deletions FluentValidation.Blazor/FluentValidator.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Forms;
using FluentValidation;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace FluentValidation
namespace Microsoft.AspNetCore.Components.Forms
{
/// <summary>
/// Add Fluent Validator support to an EditContext.
Expand Down
5 changes: 3 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This library is a direct replacement to [the default Blazor `<DataAnnotationVali
<EditForm Model="Form">


<FluentValidation.FluentValidator></FluentValidation.FluentValidator>
<FluentValidator></FluentValidator>


<div class="form-group">
Expand Down Expand Up @@ -61,12 +61,13 @@ public class FormModelValidator : AbstractValidator<FormModel>
}
```

The `<FluentValidation.FluentValidator>` component automatically detects the `Model` data type used by the parent `<EditForm>` then attempts to acquire the corresponding `FluentValidation.IValidator<T>` for that model data type.
The `<FluentValidator>` component automatically detects the `Model` data type used by the parent `<EditForm>` then attempts to acquire the corresponding `FluentValidation.IValidator<T>` for that model data type.

For this reason, [in addition to coding the usual `FluentValidation.AbstractValidator<T> Fluent Validation implementation`](https://fluentvalidation.net/start), **you are required to register the `FluentValidation.IValidator<T>` implementation in the `Startup.cs` Service Provider (Dependency Injection)**:

```cs
services.AddTransient<IValidator<CreateAccountFormModel>, CreateAccountFormModelValidator>();
// Alternatively, use FluentValidation.DependencyInjectionExtensions package (read further down below...)
```

**This effectively allows you, dear programmer, to inject required services to your validation implementations for writing amazing custom validation methods!** :fire:
Expand Down

0 comments on commit f297bdf

Please sign in to comment.