Пример #1
0
 public static IMvcCoreBuilder AddFluentValidations(this IMvcCoreBuilder builder)
 {
     return(builder.AddFluentValidation(x =>
     {
         x.RegisterValidatorsFromAssemblyContaining <ProductValidator>();
     }));
 }
Пример #2
0
 public static IMvcCoreBuilder AddDefaultFluentValidation(this IMvcCoreBuilder mvcBuilder, IEnumerable <Assembly> assemblies,
                                                          ServiceLifetime serviceLifetime = ServiceLifetime.Scoped)
 {
     return(mvcBuilder.AddFluentValidation(opt =>
     {
         ConfigureFluentValidationMvc(opt, assemblies, serviceLifetime);
     }));
 }
        public static IMvcCoreBuilder AddProspaDefaultFluentValidation(this IMvcCoreBuilder builder, Action <FluentValidationMvcConfiguration> setupOptions)
        {
            builder.AddFluentValidation(setupOptions);

            builder.Services.AddSingleton <IConfigureOptions <ApiBehaviorOptions>, ProblemJsonApiBehaviourOptionsSetup>();

            return(builder);
        }
        public static IMvcCoreBuilder AddProspaDefaultFluentValidation(this IMvcCoreBuilder builder, Type type)
        {
            builder.AddFluentValidation(config => config.RegisterValidatorsFromAssemblyContaining(type));

            builder.Services.AddSingleton <IConfigureOptions <ApiBehaviorOptions>, ProblemJsonApiBehaviourOptionsSetup>();

            return(builder);
        }
 public static void RegisterValidatorsFromAssembly(this IMvcCoreBuilder builder)
 {
     builder.AddFluentValidation(validation =>
     {
         validation.RunDefaultMvcValidationAfterFluentValidationExecutes = false;
         validation.ImplicitlyValidateChildProperties = true;
         validation.RegisterValidatorsFromAssembly(typeof(Startup).Assembly);
     });
 }
Пример #6
0
        public static IServiceCollection AddFluentValidationPlugin(this IServiceCollection services, PluginConfiguration pluginConfiguration, IMvcCoreBuilder mvcCoreBuilder)
        {
            if (pluginConfiguration.ValidatorAssemblies == null || !pluginConfiguration.ValidatorAssemblies.Any())
            {
                return(services);
            }

            mvcCoreBuilder.AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblies(pluginConfiguration.ValidatorAssemblies));

            return(services);
        }
Пример #7
0
 /// <summary>
 /// Add FluenValidation
 /// </summary>
 /// <param name="mvcCoreBuilder"></param>
 /// <param name="typeSearcher"></param>
 private static void AddFluentValidation(IMvcCoreBuilder mvcCoreBuilder, ITypeSearcher typeSearcher)
 {
     //Add fluentValidation
     mvcCoreBuilder.AddFluentValidation(configuration =>
     {
         var assemblies = typeSearcher.GetAssemblies();
         configuration.RegisterValidatorsFromAssemblies(assemblies);
         configuration.RunDefaultMvcValidationAfterFluentValidationExecutes = false;
         //implicit/automatic validation of child properties
         configuration.ImplicitlyValidateChildProperties = true;
     });
 }
Пример #8
0
 /// <summary>
 /// Add FluenValidation
 /// </summary>
 /// <param name="mvcCoreBuilder"></param>
 /// <param name="typeSearcher"></param>
 private static void AddFluentValidation(IMvcCoreBuilder mvcCoreBuilder, ITypeSearcher typeSearcher)
 {
     //Add fluentValidation
     mvcCoreBuilder.AddFluentValidation(configuration =>
     {
         var assemblies = typeSearcher.GetAssemblies();
         configuration.RegisterValidatorsFromAssemblies(assemblies);
         configuration.DisableDataAnnotationsValidation = true;
         //implicit/automatic validation of child properties
         configuration.ImplicitlyValidateChildProperties = true;
     });
 }
Пример #9
0
        /// <summary>
        /// Adds PineBlog Razor Pages services to the services collection.
        /// </summary>
        /// <param name="builder">The Microsoft.Extensions.DependencyInjection.IMvcCoreBuilder.</param>
        public static IMvcCoreBuilder AddPineBlogRazorPages(this IMvcCoreBuilder builder)
        {
            ConfigureServices(builder.Services);

            builder.AddApplicationPart(typeof(Controllers.FileController).Assembly);
            builder.AddRazorPages(SetRazorPagesOptions);
            builder.AddMvcOptions(options =>
            {
                options.Filters.Add <PineBlogViewDataAsyncPageFilter>();
            });
            builder.AddFluentValidation();

            return(builder);
        }
Пример #10
0
        /// <summary>
        /// Adds PineBlog Razor Pages services to the services collection.
        /// </summary>
        /// <param name="builder">The Microsoft.Extensions.DependencyInjection.IMvcCoreBuilder.</param>
        public static IMvcCoreBuilder AddPineBlogRazorPages(this IMvcCoreBuilder builder)
        {
            ConfigureServices(builder.Services);

            builder.AddApplicationPart(typeof(Controllers.FileController).Assembly);
            builder.AddRazorPages(option =>
            {
                option.Conventions.AuthorizeAreaFolder("Admin", "/");
                option.Conventions.AddAreaPageRoute("Blog", "/Post", PineBlogConstants.BlogAreaPath + "/{*slug}");
            });
            builder.AddMvcOptions(options =>
            {
                options.Filters.Add <PineBlogViewDataAsyncPageFilter>();
            });
            builder.AddFluentValidation();

            return(builder);
        }
Пример #11
0
 /// <summary>
 /// Add FluentValidations configuration
 /// </summary>
 /// <param name="builder"></param>
 /// <returns></returns>
 public static IMvcCoreBuilder AddFluentValidations(this IMvcCoreBuilder builder) =>
 builder.AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining <ApiVersioning>());
Пример #12
0
 /// <summary>
 /// Register fluent validation.
 /// </summary>
 /// <param name="builder">MVC builder.</param>
 /// <returns>MVC builder.</returns>
 public static IMvcCoreBuilder AddFluentValidation(this IMvcCoreBuilder builder)
 => builder.AddFluentValidation(o =>
 {
     o.RegisterValidatorsFromAssembly(Assembly.GetExecutingAssembly());
     o.RunDefaultMvcValidationAfterFluentValidationExecutes = false;
 });
Пример #13
0
 public static IMvcCoreBuilder AddFluentValidation(this IMvcCoreBuilder builder)
     => builder.AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining<WhateverModelValidator>());
Пример #14
0
 public static IMvcCoreBuilder AddFluentValidation(this IMvcCoreBuilder builder) =>
 builder.AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining <TaxaDeJurosValidator>());