Skip to content

Commit

Permalink
Registrer new validators in DI container
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarne committed Jan 4, 2024
1 parent df7acc8 commit 698500c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/Altinn.App.Core/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Altinn.App.Core.Features.PageOrder;
using Altinn.App.Core.Features.Pdf;
using Altinn.App.Core.Features.Validation;
using Altinn.App.Core.Features.Validation.Default;
using Altinn.App.Core.Implementation;
using Altinn.App.Core.Infrastructure.Clients.Authentication;
using Altinn.App.Core.Infrastructure.Clients.Authorization;
Expand Down Expand Up @@ -133,7 +134,7 @@ public static void AddAppServices(this IServiceCollection services, IConfigurati
{
// Services for Altinn App
services.TryAddTransient<IPDP, PDPAppSI>();
services.TryAddTransient<IValidationService, ValidationService>();
AddValidationServices(services);
services.TryAddTransient<IPrefill, PrefillSI>();
services.TryAddTransient<ISigningCredentialsResolver, SigningCredentialsResolver>();
services.TryAddSingleton<IAppResources, AppResourcesSI>();
Expand Down Expand Up @@ -177,6 +178,18 @@ public static void AddAppServices(this IServiceCollection services, IConfigurati
}
}

private static void AddValidationServices(IServiceCollection services)
{
services.TryAddTransient<IValidationService, ValidationService>();
services.TryAddTransient<IFormDataValidator, RequiredLayoutValidator>();
services.TryAddTransient<IFormDataValidator, ExpressionValidator>();
services.TryAddTransient<IFormDataValidator, DataAnnotationValidator>();
services.TryAddTransient<IFormDataValidator, LegacyIInstanceValidatorFormDataValidator>();
services.TryAddTransient<IDataElementValidator, DefaultDataElementValidator>();
services.TryAddTransient<ITaskValidator, LegacyIInstanceValidatorTaskValidator>();
services.TryAddTransient<ITaskValidator, DefaultTaskValidator>();
}

/// <summary>
/// Checks if a service is already added to the collection.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Altinn.App.Core.Internal.App;
using Altinn.App.Core.Internal.AppModel;
using Altinn.App.Core.Internal.Data;
using Altinn.App.Core.Internal.Process.Elements;
using Altinn.App.Core.Models.Validation;
using Altinn.Platform.Storage.Interface.Models;
using Microsoft.Extensions.DependencyInjection;
Expand Down

0 comments on commit 698500c

Please sign in to comment.