You can use Validator to accomplish this.
var context = new ValidationContext(u, serviceProvider: null, items: null);
var validationResults = new List<ValidationResult>();
bool isValid = Validator.TryValidateObject(u, context, validationResults, true);
More Related Contents:
- Setting the default JSON serializer in ASP.NET MVC
- How to get DropDownList SelectedValue in Controller in MVC
- Weird Error Upgrading ASP.NET MVC from 4 to 5
- How to pass IEnumerable list to controller in MVC including checkbox state?
- ValidateAntiForgeryToken purpose, explanation and example
- Passing data between different controller action methods
- How does MVC 4 List Model Binding work?
- Proper JSON serialization in MVC 4
- ASP.NET MVC 4 C# HttpPostedFileBase, How do I Store File
- ASP.NET MVC get textbox input value
- How can I change IIS Express port for a site
- How to clear browser cache on browser back button click in MVC4?
- ASP.Net MVC: Calling a method from a view
- MVC 4 how pass data correctly from controller to view
- CustomAttribute reflects html attribute MVC5
- pass two models to view [duplicate]
- MVC 5 Dynamic Rows with BeginCollectionItem
- Return HTML from ASP.NET Web API
- ASP.NET MVC 4 + Ninject MVC 3 = No parameterless constructor defined for this object
- Test method is inconclusive: Test wasn’t run. Error?
- How to add ASP.NET Membership Provider in a Empty MVC 4 Project Template?
- {version} wildcard in MVC4 Bundle
- How to add and get Header values in WebApi
- Web API in MVC solution in separate project
- System.Web.HttpContextBase’ does not contain a definition for ‘Current’ MVC 4 with Elmah Logging
- How to route EVERYTHING other than Web API to /index.html
- MVC4 – Bundling does not work when optimizations are set to true
- How to create Select List for Country and States/province in MVC
- LINQ to Entities does not recognize the method ‘System.String ToString()’ method in MVC 4
- There is no ViewData item of type ‘IEnumerable’ that has the key country