validationattribute Questions

6

Is there a way to validate GUID datatype? I'm using validation attributes. http://msdn.microsoft.com/en-us/library/ee707335%28v=vs.91%29.aspx
Pinafore asked 30/11, 2011 at 23:43

3

Solved

Problem I know there is a lot of ways of doing Model validation within MVC, and there is quite a lot of documentation regarding this topic. However, I'm not quite sure what's the best approach for...

7

I was looking for some advice on the best way to go about implementing a validation attribute that does the following. Model public class MyInputModel { [Required] public int Id {get;set;} p...
Lyndell asked 12/9, 2011 at 16:18

3

Solved

I am developing a website built on EntityFrameworkCore and targeting ASP.NET Core 2.1. I want to specify an error message for an enum field in my model like so: [Required(ErrorMessage = "Select an...

5

Solved

Basically what I'm trying to figure out is how to require at least one of two fields to be filled out in a View. In my View, I have two text fields called ISBN and ISBN13. It doesn't matter which ...
Intrinsic asked 15/4, 2017 at 14:38

2

How to localize standard error messages of validation attributes in ASP.NET Core (v2.2)? For Example, [Required] attribute has this error message "The xxx field is required."; [EmailAddress] has "T...

0

I have a custom TagHelper which extends the OOTB InputTagHelper. I am conditionally adding attributes to it based on the presence of a custom ValidationAttribute on the model property associated wi...

1

Solved

I need to return customized validation result (response) invalidation attributes in ASP.Net core Web API This is the ValidationAttribute I have created. class MaxResultsAttribute : ValidationAttrib...
Uncircumcised asked 9/10, 2020 at 6:22

8

Solved

I am trying to use a regular expression to validate a phone number and return an error when an invalid number or phone number is submitted. MVC Code: <ol class="row"> <li class="cell" ...
Enneahedron asked 6/3, 2015 at 18:0

2

Solved

Context: creating a jsonP service with mvc controller methods which provides a definition of formfields including all validation rules. My problem is that I do not know how to serialize the valida...
Grosswardein asked 20/6, 2011 at 14:0

4

Solved

I've a model kind of complicated. I have my UserViewModel which has several properties and two of them are HomePhone and WorkPhone. Both of type PhoneViewModel. In PhoneViewModel I have CountryCod...

1

Solved

I'm having a bit of trouble getting my head around testing my custom validation attribute. As the method signature is protected when I invoke the IsValid method in my unit test, I can't pass in a M...
Raffo asked 13/1, 2016 at 11:44

1

Solved

I created a custom ValidationAttribute that targets a class. This validates correctly whenever I try to call the Validator.TryValidateObject. But when I have other ValidationAttribute in the proper...
Puree asked 5/2, 2014 at 7:31

1

Solved

I've been representing an enum within my razor view as a hidden field, which is posted back to an action result. I've noticed that when it binds the string value provided within the HTML, it autom...
Zacek asked 17/10, 2014 at 12:40

2

Solved

I want to create custom client-side validator, but I want define validation rules via Data Annotations attributes at business logic layer. How can I access model validation attributes in runtime? ...
Cooncan asked 28/10, 2013 at 14:57

3

Solved

I want to create a custom validation attribute, in which I want to compare the value of my property with another property's value in my model class. For example I have in my model class: ... publ...
Differentiable asked 14/8, 2012 at 19:29

2

Solved

I'm using a base contact model which other custom contact models classes inherit. public class BaseContactModel { [Required(ErrorMessage = "Firstname is required")] public virtual string FirstNa...
Keitel asked 8/10, 2012 at 19:56

3

Solved

I have created a custom CompareLessThan validation attribute by copying the ASP.NET MVC 3 CompareAttribute and instead of checking for equality, I check to see that one property is less than anothe...

2

Solved

We have a need within some of our logic to iterate through the properties of a model to auto-bind properties and want to extend the functionality to include the new dataannotations in C# 4.0. At t...

1

Solved

I tried to create a custom ValidationAttribute: public class RollType : ValidationAttribute { public override bool IsValid(object value) { return false; // just for trying... } } Then I crea...
Frow asked 25/4, 2012 at 6:12

1

Solved

Given a ViewModel that looks like this: public class Login { [Required] public string Username { get; set; } [Required, CustomValidator] public string Password { get; set; } } And a View li...
Stromberg asked 8/11, 2010 at 2:1
1

© 2022 - 2024 — McMap. All rights reserved.