File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
src/Atc.Rest.MinimalApi/Filters/Endpoints Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,18 @@ private static async Task ValidateNestedFromBodyProperties(
145145
146146 // Create ValidationContext dynamically
147147 var contextType = typeof ( ValidationContext < > ) . MakeGenericType ( propertyType ) ;
148- if ( Activator . CreateInstance ( contextType , propertyValue ) is not FluentValidation . IValidationContext validationContext )
148+ FluentValidation . IValidationContext ? validationContext ;
149+
150+ try
151+ {
152+ validationContext = Activator . CreateInstance ( contextType , propertyValue ) as FluentValidation . IValidationContext ;
153+ }
154+ catch ( Exception ex ) when ( ex is MissingMethodException or TargetInvocationException or TypeInitializationException )
155+ {
156+ continue ;
157+ }
158+
159+ if ( validationContext is null )
149160 {
150161 continue ;
151162 }
You can’t perform that action at this time.
0 commit comments