Skip to content

Commit

Permalink
Set .NET version
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreuCodina committed Nov 15, 2023
1 parent a617d31 commit de6a5ee
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
<LangVersion>12</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
2 changes: 0 additions & 2 deletions src/CrossValidation/ModelValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public IValidation<TField> Field<TField>(
string? fieldDisplayName = null,
[CallerArgumentExpression(nameof(field))] string fieldName = default!)
{
// if ()

var fieldPath = fieldName.Contains('.')
? fieldName.Substring(fieldName.IndexOf('.') + 1)
: fieldName;
Expand Down
18 changes: 8 additions & 10 deletions src/CrossValidation/ValidationOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,19 +218,17 @@ public void HandleException(BusinessException exception, ValidationContext conte
var exceptionToAdd = context.Exception ?? (Exception ?? exception);
AddException(exceptionToAdd, context);

if (context is {ValidationMode: ValidationMode.StopOnFirstError})
if (context.ValidationMode is ValidationMode.StopOnFirstError
&& context.ExceptionsCollected.Count == 1)
{
if (context.ExceptionsCollected.Count == 1)
if (CustomExceptionToThrow is not null)
{
if (CustomExceptionToThrow is not null)
{
throw (Exception)Activator.CreateInstance(
CustomExceptionToThrow,
CreateParametrizedExceptionMessage(context.ExceptionsCollected[0]))!;
}

throw context.ExceptionsCollected[0];
throw (Exception)Activator.CreateInstance(
CustomExceptionToThrow,
CreateParametrizedExceptionMessage(context.ExceptionsCollected[0]))!;
}

throw context.ExceptionsCollected[0];
}
}

Expand Down

0 comments on commit de6a5ee

Please sign in to comment.