This project was created for the purpose of experiment. No longer supported!
- Profile Validations.
- Works with ModelState Errors.
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();
}
}
Install DynamicVNET.AspNetCore from the package manager console:
PM> Install-Package DynamicVNET.Lib.AspNetCore -Version 1.0.1-alpha
DynamicVNET.AspNetCore is Copyright © 2018 Rasul Huseynov and lincensed under the MIT license.