Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Latest commit

 

History

History
76 lines (64 loc) · 2.2 KB

README.md

File metadata and controls

76 lines (64 loc) · 2.2 KB

DynamicVNET For Asp.Net Core - Overview [BETA]

NuGet

This project was created for the purpose of experiment. No longer supported!

Support

  • Profile Validations.
  • Works with ModelState Errors.

Asp.Net Core Example

Validation Model

// Simulation
 public class ViewModel
 {
        public string Id { get; set; }
 }

Step : Startup.ConfigureServices

public void ConfigureServices(IServiceCollection services)
{
            services.AddProfileValidation(validator =>
            {
                validator.AddProfile<ViewModel>("StrProfile", marker =>
                {
                    marker
                    .Required(x => x.Id)
                       .StringLen(x => x.Id, 3);
                });

                validator.AddProfile<ViewModel>("PhoneProfile", marker =>
                {
                    marker
                        .Required(x => x.Id)
                        .PhoneNumber(x => x.Id)
                        .Range(x => x.Id, 7, 12);
                });
            });

            // other .......
}

Step : Any Controller Action Implementation

public class HomeController : Controller
{
        public IActionResult Index()
        {
            return View();
        }

        [ProfileVNET]
        public IActionResult Contact([ProfileBind("PhoneProfile")]ViewModel model,[ProfileBind("StrProfile")]ViewModel model2)
        {
            if(!ModelState.IsValid)
                ViewData["Message"] = "Error Model";
            else
                ViewData["Message"] = "Success Model";

            return View();
        }
}

Where can I get it?

Install DynamicVNET.AspNetCore from the package manager console:

PM> Install-Package DynamicVNET.Lib.AspNetCore -Version 1.0.1-alpha

License & Copyright

DynamicVNET.AspNetCore is Copyright © 2018 Rasul Huseynov and lincensed under the MIT license.