4
4
using Microsoft . AspNetCore . Components . Forms ;
5
5
using Morris . Blazor . Validation ;
6
6
using System ;
7
- using System . Collections ;
8
7
using System . Collections . Generic ;
9
8
using System . Linq ;
10
9
using System . Reflection ;
@@ -16,18 +15,20 @@ public class FluentValidationValidatorProvider : IValidationProvider
16
15
{
17
16
public void InitializeEditContext (
18
17
EditContext editContext ,
19
- IServiceProvider serviceProvider )
18
+ IServiceProvider serviceProvider ,
19
+ ValidationProperties properties )
20
20
{
21
21
if ( editContext == null )
22
22
throw new ArgumentNullException ( nameof ( editContext ) ) ;
23
23
if ( serviceProvider == null )
24
24
throw new ArgumentNullException ( nameof ( serviceProvider ) ) ;
25
+ properties ??= ValidationProperties . Set ;
25
26
26
27
var messages = new ValidationMessageStore ( editContext ) ;
27
28
editContext . OnValidationRequested +=
28
29
( sender , eventArgs ) =>
29
30
{
30
- _ = ValidateModel ( ( EditContext ) sender , messages , serviceProvider ) ;
31
+ _ = ValidateModel ( ( EditContext ) sender , messages , serviceProvider , properties ) ;
31
32
} ;
32
33
33
34
editContext . OnFieldChanged +=
@@ -40,7 +41,8 @@ public void InitializeEditContext(
40
41
private async Task ValidateModel (
41
42
EditContext editContext ,
42
43
ValidationMessageStore messages ,
43
- IServiceProvider serviceProvider )
44
+ IServiceProvider serviceProvider ,
45
+ ValidationProperties properties )
44
46
{
45
47
if ( editContext == null )
46
48
throw new ArgumentNullException ( nameof ( editContext ) ) ;
@@ -89,7 +91,7 @@ private void GetParentObjectAndPropertyName(
89
91
Type modelType = model . GetType ( ) ;
90
92
while ( propertyPathParts . Count > 1 )
91
93
{
92
- var name = propertyPathParts . Dequeue ( ) ;
94
+ string name = propertyPathParts . Dequeue ( ) ;
93
95
94
96
string propertyIndexString = null ;
95
97
int bracketIndex = name . IndexOf ( '[' ) ;
0 commit comments