Top "Validationattribute" questions

Used for classes Validation Attribute Classes in .NET within the System.

Phone Number Validation MVC

I am trying to use a regular expression to validate a phone number and return an error when an invalid …

c# regex asp.net-mvc jquery-validate validationattribute
RequiredIf Conditional Validation Attribute

I was looking for some advice on the best way to go about implementing a validation attribute that does the …

asp.net-mvc-3 validationattribute
Custom validation attribute that compares the value of my property with another property's value in my model class

I want to create a custom validation attribute, in which I want to compare the value of my property with …

c# asp.net-mvc razor validationattribute
DataAnnotations "NotRequired" attribute

I've a model kind of complicated. I have my UserViewModel which has several properties and two of them are HomePhone …

c# asp.net-mvc asp.net-mvc-3 data-annotations validationattribute
Validating Enum Values within C# MVC. Partial validation occurs - How to change validation behaviour?

I've been representing an enum within my razor view as a hidden field, which is posted back to an action …

c# asp.net-mvc razor validation validationattribute
Why does Validator.TryValidateObject does not validate class if I have validation attribute in a property?

I created a custom ValidationAttribute that targets a class. This validates correctly whenever I try to call the Validator.TryValidateObject. …

c# validation annotations validationattribute
Best approach for complex model/submodel validation (MVC)

Problem I know there is a lot of ways of doing Model validation within MVC, and there is quite a …

c# asp.net-mvc model-view-controller model-validation validationattribute
ASP.NET MVC ValidationAttribute Get Other Property Display Name

I have created a custom CompareLessThan validation attribute by copying the ASP.NET MVC 3 CompareAttribute and instead of checking for …

asp.net-mvc validation client-side-validation validationattribute
Custom ValidationAttribute doesn't work

I tried to create a custom ValidationAttribute: public class RollType : ValidationAttribute { public override bool IsValid(object value) { return false; // just …

c# asp.net-mvc-3 validationattribute
Get Data Annotations attributes from model

I want to create custom client-side validator, but I want define validation rules via Data Annotations attributes at business logic …

c# asp.net asp.net-mvc data-annotations validationattribute