data-annotations Questions

10

I have a strongly-typed view which has a DropDownListFor attribute on it. Each item in the dropdown list is represented by a GUID. What I'm after is a way to validate if a user selects an item f...
Aquanaut asked 25/8, 2011 at 8:55

11

Solved

I would like to specify that a decimal field for a price must be >= 0 but I don't really want to impose a max value. Here's what I have so far...I'm not sure what the correct way to do this is. [...
Worship asked 27/7, 2010 at 15:41

7

I have an object graph sprinkled with DataAnnotation attributes, where some properties of objects are classes which themselves have validation attributes, and so on. In the following scenario: pu...
Violaceous asked 5/10, 2011 at 15:7

1

Solved

I am porting an application from Asp.net Controllers to Asp.net Minimal-Apis. The current project is using model-based DataAnnotations. Controllers do model validation out of the box but MinApi doe...

4

Solved

I have this Enum (Notebook.cs): public enum Notebook : byte { [Display(Name = "Notebook HP")] NotebookHP, [Display(Name = "Notebook Dell")] NotebookDell } Also this property in my class (TI...
Pyelitis asked 26/5, 2015 at 19:43

4

Solved

I want to be able to do this: string email = "[email protected]"; bool isValid = IsValidEmail(email); //returns true ...but use the logic Microsoft has already given us in EmailAddressAttri...
Reception asked 29/4, 2016 at 21:37

9

Solved

I have a property in my view model as follows: [Editable(false)] [Display(Name = "Date")] [DisplayFormat(DataFormatString = "{0:yyyy/MM/dd}", ApplyFormatInEditMode = true)] public DateTime Movemen...
Cheekpiece asked 22/5, 2013 at 17:15

3

Solved

What are the operative differences between these two validation packages when used for ASP.NET MVC validatation? They seem to have similar objects, all the way to their object names. Is one related...
Necaise asked 24/7, 2011 at 14:43

6

Solved

I have a viewmodel with an Id property [Required] public int Id { get; set; } But I think this attribute is working only for string properties. When no Id is set, Id has value 0 and the model i...
Ultramundane asked 12/7, 2011 at 10:46

4

Solved

Is there a way to make a data annotation conditional? I have a table Party where I store both organisations and persons. If I'm adding an organisation I don't want the field surname to be required,...
Housecoat asked 23/6, 2011 at 11:53

13

Solved

I've got a view model like this: public class SignUpViewModel { [Required(ErrorMessage = "Bitte lesen und akzeptieren Sie die AGB.")] [DisplayName("Ich habe die AGB gelesen und akzeptiere diese....
Hypanthium asked 11/2, 2010 at 14:47

4

I am trying to convert VIA (VGG Image Annotator) JSON file to Labelme JSON file, but the only problem is imageData attribute in Labelme. I am not able to upload my JSON file into Labelme tool witho...
Overt asked 12/7, 2019 at 10:6

10

Solved

I have a .Net MVC 5 application that is using Data Annotations, Entity-Framework Jquery 2.1.3 and Jquery UI 1.11.4. When I render an edit form with an input of type date using the UK format "dd/M...
Dunfermline asked 12/6, 2015 at 8:43

12

Solved

I have a class like this: public class Document { public int DocumentType{get;set;} [Required] public string Name{get;set;} [Required] public string Name2{get;set;} } Now if I put a [Requ...
Cryptogram asked 14/10, 2014 at 7:20

18

Solved

I'm trying to use DataAnnotations in my WPF project to specify a maximum length of strings, with the following: using System.ComponentModel.DataAnnotations; However, I get the error The type ...
Nissie asked 16/4, 2012 at 12:50

16

Solved

This is happening when I try to create the entity using a Create style action in Asp.Net MVC 2. The POCO has the following properties: public int Id {get;set;} [Required] public string Message {...
Parasang asked 26/1, 2010 at 22:1

2

[Table("UserMaster")] public class UserMaster { public UserMaster() { this.Roles = new List<Role>(); } [Key] public int UserId { get; set; } public string UserName { get; set; } pu...
Encephaloma asked 6/9, 2013 at 1:44

6

Solved

I am using Data Annotations to validate my Model in ASP.NET MVC. This works well for action methods that has complex parameters e.g, public class Params { [Required] string Param1 {get; set;} ...
Melodeemelodeon asked 26/4, 2010 at 22:4

2

In my .net core 2.0 Web API I am using EnumDataType() validation attribute on my model property. When the validation fails the custom error message is empty. I am not sure why it is happening - [En...
Inimical asked 6/4, 2018 at 11:22

5

Solved

I have the following code: [DisplayName("58.Date and hour of birth")] [DataType(DataType.DateTime, ErrorMessage = "Please enter a valid date in the format dd/mm/yyyy hh:mm")] [Range(typeof(Date...
Houseraising asked 22/3, 2011 at 11:23

4

Solved

How can I change that messages for all int fields so that instead of saying: The field must be a number in English, it shows: El campo tiene que ser numerico in Spanish. Is there are a way?

3

I'm using the new MVC6 framework with Visual Studio 2015, and suddenly all my Data Annotations stopped working. All of them, without me changing the code. public sealed class RegisterUser { [Requ...
Minstrelsy asked 15/8, 2016 at 20:8

1

Solved

I want to convert my labels in yolo format to coco format I have tried https://github.com/Taeyoung96/Yolo-to-COCO-format-converter And Pylabel They all have a bugs. I want to train on detectron 2 b...

5

Solved

I'm using CodeFirst Entitty framework 5. I have a class representing a user. public class User { [Key] public int UserId { get; set; } [Url] [DataType(DataType.Url)] [Required(AllowEmptyStri...
Perithecium asked 2/10, 2013 at 11:7

2

Solved

I am trying to create a custom validation attribute. public class PhoneValidator : ValidationAttribute { public override bool IsValid(object value) { return new RegularExpressionAttribute(@"^[+...
Butts asked 21/5, 2014 at 10:44

© 2022 - 2025 — McMap. All rights reserved.