Skip to content

Instantly share code, notes, and snippets.

@gistlyn
Created April 12, 2021 00:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gistlyn/f517c6f8f63bef5178c46b8dcd0ef5ca to your computer and use it in GitHub Desktop.
Save gistlyn/f517c6f8f63bef5178c46b8dcd0ef5ca to your computer and use it in GitHub Desktop.
validationsource
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