Created
April 12, 2021 00:58
-
-
Save gistlyn/f517c6f8f63bef5178c46b8dcd0ef5ca to your computer and use it in GitHub Desktop.
validationsource
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Extensions.DependencyInjection; | |
using ServiceStack; | |
using ServiceStack.Data; | |
using ServiceStack.Validation; | |
namespace MyApp | |
{ | |
public class ConfigureValidation : IConfigureServices, IConfigureAppHost | |
{ | |
public void Configure(IServiceCollection services) | |
{ | |
// Add support for dynamically generated db rules | |
services.AddSingleton<IValidationSource>(c => | |
new OrmLiteValidationSource(c.Resolve<IDbConnectionFactory>())); | |
} | |
public void Configure(IAppHost appHost) | |
{ | |
appHost.Plugins.Add(new ValidationFeature()); | |
appHost.Resolve<IValidationSource>().InitSchema(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment