Questions tagged [data-annotations]

Data Annotations are used by frameworks such as ASP.NET MVC to enable a model-based validation approach and enforce consistent validation throughout the application, both on client and server side. They were first introduced in ASP.NET MVC 2. In addition to ASP.NET MVC, they can also be used with other technologies such as Entity Framework, either through manual placement of attributes on properties, or automatic generation with T4 templates.

Filter by
Sorted by
Tagged with
0 votes
0 answers
24 views

How to override Index's IsUnique in inherited class

I have following base class [Index(nameof(FullName), IsUnique = true)] public abstract class Entity { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; }...
DotNet Developer's user avatar
0 votes
0 answers
29 views

How do I prevent a user other than entering a whole number 1-9? [duplicate]

In this issue I am using C# ASP.NET Core 6. I have an input in my model that I need to be entirely 1 digit from 1-9. I would like to not have to validate it in javascript since I have more validation ...
Cade's user avatar
  • 11
0 votes
0 answers
15 views

How to Enable Dragging in this react Component?

This code, is drawing a rectangle in the page, using the geometry. The Rectangle will be generated only using the basic styling attributes like height, width, left and top. The dragging is not getting ...
gowtham_wick's user avatar
-2 votes
2 answers
66 views

Regular Expression for A-Z, Dash using Data Annotations

I need a regular expression for a URL-friendly slug, which can only contain lowercase letters and hyphens. It can't start or end with a hyphen and can't have more than one consecutive dash. It will be ...
Kenneth R. Jones's user avatar
0 votes
0 answers
6 views

Is it possible to use translations for System.ComponentModel.DataAnnotations without aspnet mvc?

I'm using data annotations validation in a console application. I'd like to translate the error messages while using the default attributes (so not specifying specific resource types / keys). I've ...
Erwin van der Valk's user avatar
2 votes
1 answer
126 views

The DataType and Range data annotations do not localize the error message

I don't understand why in an asp.net 7.0 razor pages application the localization of data annotations error messages works for all attributes except for the "DataType" attribute where the ...
steve fax's user avatar
0 votes
1 answer
58 views

System.ComponentModel.DataAnnotations 2023

What's changed? I've had this C# Razor app (SQL backend) developed and deployed in production for 3 years now. Recently, I've added 3 new tables in SQL and rather than use Package Manager console to ...
GCDevOps's user avatar
1 vote
1 answer
35 views

Disable data annotation for specific DTO

I would like to disable data annotation validation for some case. You assume that we have two DTO and two endpoint public class CreateBulkProductDto { [Required] public List<...
CaglarAyhan's user avatar
0 votes
0 answers
70 views

My [Column(TypeName="varchar(10)")] does not work

I set attribute to benefitID to [Column(TypeName="varchar(10)")] but when I run it benefit is nvarchar(450). [Key] [Column(TypeName="varchar(10)")] [StringLength(20)] [Required] ...
Chiến Trần's user avatar
0 votes
0 answers
18 views

Displaying messages in different languages in Fluent validation

public class ExpenditureCreateValidator : AbstractValidator<ExpenditureCreateVM> { private readonly List<string> _allowedExtensions; public ExpenditureCreateValidator() { ...
Dilara PINAR's user avatar
0 votes
0 answers
26 views

Validation language settings

Consider: public class FilePathAttribute : ValidationAttribute { private readonly string[] _extensions; public FilePathAttribute(string[] extensions) { _extensions = ...
Aizolex's user avatar
0 votes
0 answers
11 views

.NET ComponentModel.DataAnnotations RegularExpression not working with BsonIgnoreExtraElements

I have to put DataAnnotations on certain fields to block scripts being passed in API request. I am using Regular expression annotation and it is working in 3 Model classes however, it is not working ...
goodmayhem's user avatar
  • 3,374
0 votes
0 answers
3 views

my code for data markup and annotation is not functioning as I expect

I encountered a problem while creating a data markup and annotation project and I sincerely request help in resolving it. Problem: My task is to label a large amount of data, including images and text,...
makskovalchuk's user avatar
1 vote
2 answers
140 views

ASP.NET MVC tightening up password requirement using MembershipPasswordAttribute

I am working on tightening up the password on my site, and wanted to see if I can use the MembershipPassword? I have tried to use the code below in my model but I am not getting any error message. ...
Jefferson's user avatar
  • 127
0 votes
0 answers
30 views

How to get specific columns in EF Core 7 with ANNOTATIONS

I am trying to learn how to use EF Core. I am using VB, with EF Core 7, MySQL DB and I am trying to do a localized App where the columns of a table are localized. I scaffolded the DB and I have these ...
Andy's user avatar
  • 1
0 votes
0 answers
25 views

Can't get dropdown to appear after creating entity

I just wanted to be able for a user to select from a dropdown if their id number was a ssn or ein. I created a Farm entity and I wanted the user to select from a dropdown using Datalist whether or not ...
Christopher Blick's user avatar
0 votes
0 answers
18 views

EF Core DataAnnotations not used in Razor page

I am using Html.LabelFor in my razor page. The auto generated EF entities I have are: public partial class Projectinformation { public int Id { get; set; } // [Display(Name = "Project ...
Paul Gibson's user avatar
0 votes
1 answer
49 views

(c#) DataAnnotation: how handle an attribute that MUST be empty?

I'm creating a model with a strong use of System.ComponentModel.DataAnnotations and ExpressiveAnnotations. But I need a suggestion to handle this case: If attribute1 has value "ABC" then ...
Cristian Agresta's user avatar
-1 votes
2 answers
46 views

Validation attribute when set value from server side .Net Core [duplicate]

When I set value from server side to prop has a validation attribute "MaxLength", the application not throw exception. public class Student { public Guid Id { get; set; } ...
Mahmoud Alakrami's user avatar
1 vote
0 answers
76 views

PasswordPropertyText vs DataType(DataType.Password) attribute

What exactly is the difference between these two .NET attributes: [PasswordPropertyText] => PasswordPropertyTextAttribute [DataType(DataType.Password)] => DataTypeAttribute with a DataType ...
Alexandra Valkova's user avatar
0 votes
0 answers
99 views

How to localize the property names in the error messages in the ASP.NET Core 7 Web API response?

I have gone through quite a bit of SO questions like: Localise Display DataAnnotation without the Name Attribute in .NET Core 5 ViewModel Display Name is problem on Data Annotation ErrorMessage (The {...
Shankar's user avatar
  • 1,634
0 votes
0 answers
19 views

Exception to the rule - how to override a required attribute on one item when using data annotations with a list [duplicate]

I have a list of objects for my ASP.NET MVC model List<NameAddressModel>. In this abbreviated example, we're only looking at the first name. The model has the [Required] attribute, which will ...
NovaDev's user avatar
  • 2,787
0 votes
1 answer
97 views

Blazor DataAnnotations Compare validation conflicts with browser autocomplete

I have a Blazor server app that has a form with two password inputs, "new password" and "confirm password". I'm using DataAnnotations Compare attribute to validate that the two ...
Boatmarker's user avatar
0 votes
0 answers
74 views

NER Model Training using spacy

I am struggling during training an NER model using spacy transformer in GPU. This NER is related to build an accurate CV Parser. The main challenge here is that I can't give a lot of data to this ...
ALOK MISHRA's user avatar
0 votes
1 answer
95 views

DataAnnotationsModelMetadataProvider in ASP.NET Core 6.0

I am migrating a project from ASP.NET MVC to ASP.NET Core 6.0. I have the following class in the ASP.NET MVC project: public class CustomModelMetadataProvider : DataAnnotationsModelMetadataProvider { ...
csharpdev's user avatar
0 votes
0 answers
20 views

Annotating text data with ontologies

I have a list of plant organisms (text) and I want to annotate them with ontologies(Plant ontology, Crop Ontology, Food Ontology, etc), I was using ontology lookup services to do the annotation ...
Agnes's user avatar
  • 1
0 votes
0 answers
24 views

Why is the Model's RequiredIf Data Annotation not working for an HTML Kendo Grid

The grid has multiple columns with a dependency on one of them. The delivery type column is one of three value characters (E)mail, (P)ostal, and (C)ampus mail. If P or C are used the user has to ...
user avatar
0 votes
1 answer
47 views

What is the best tool to augment DOTA like custom dataset?

My dataset is annotated using rotated bounding box annotation tool having (x1y1 x2y2 x3y3 x4y4 class category) is label format (same as DOTA). My data directory contains: images train (txt labels) ...
user181925's user avatar
0 votes
0 answers
18 views

ASP.NET controller data annotation validation: Class-level validation attribute called as if property-level

I have something roughly equivalent to the following code. A POSTed query object, that contains a sub-object with some details, and some custom validation code to glue the validation of the sub-...
Kile Kasmir Asmussen's user avatar
0 votes
0 answers
29 views

Can I validate formdata in a C# endpoint for string length, maximum int values, and regular expression matching?

I'm trying to perform some server-side validations in C# on form data that is being posted to an endpoint using JavaScript. I would like to restrict the lengths of some string properties, the range of ...
Elisheva's user avatar
0 votes
1 answer
200 views

RequiredIf data annotation attribute not now showing error message

I use this solution for RequiredIf. The logic works fine and a ValidationResult with the correct error message is being returned. To display the error message I do the standard: <ValidationMessage ...
Ivan Debono's user avatar
0 votes
0 answers
99 views

merging two annotated data sets without removing any information

I have the following anndata sets 1- AnnData object with n_obs × n_vars = 750 × 5000 obs: 'cell_type', 'n_genes', 'species' var: 'n_cells', 'highly_variable', 'highly_variable_rank', 'means', '...
M.Z's user avatar
  • 21
0 votes
0 answers
39 views

how to avoid spring data JPA to insert a particular field: @Column(name="cn", insertable = false, updatable=false) did not worked

I have an entity with a field called cn which means creators name. Creators Name comes from another table. The field in this entity is creator_id. After reading the documentation I was hopping to be ...
John A.'s user avatar
0 votes
1 answer
196 views

Data annotation localization in .net core api

I'm trying to localize data annotation for multi lingual support, while doing so I'm getting an access modifier error message, more details are divulged below. Also If someone can provide me with ...
Amey Rane's user avatar
0 votes
0 answers
71 views

Data annotation Required in Entity Framework Core with MySQL seems to work incorrectly

In my project, I have a table: [Table("users")] public class User { [Column("id"), Key, Required] public int Id { get; set; } [Column("name"), MaxLength(64)] ...
The_Honortaker's user avatar
1 vote
0 answers
161 views

Mapping issue with Dapper: Stored procedure result not correctly mapped to class properties

I am calling a stored procedure from my C# code and want to map the result to my custom class. However when calling the method the mapping is not happening correctly when using the column annotations. ...
Levi Geeraerd's user avatar
0 votes
0 answers
16 views

How do i create a task that contains multiple videos?

Now the system creates a different task for every video, and I want related videos to be different jobs of the same task. How can I do that? I have multiple videos of the same people from different ...
Michal Shamir's user avatar
0 votes
1 answer
48 views

Custom Validation for Generic Types in c#

Given entity types as below List<User> users = new List<User> { new User { Name = "John", Hobbies = new List<...
lacoder's user avatar
  • 1,293
0 votes
0 answers
27 views

Dataset Annotation With two labels instead of single label for object detection

"Hi, I want to annotate my dataset with two-labels and then train two models to predict both the labels. Which annotation tool I can use for it. I searched around but could not found anything ...
user181925's user avatar
-1 votes
1 answer
217 views

Regular Expression for name validation containing A-Z a-z 0-9 apostrophe ' and dash -

I'm trying to validate names that contains A-Z a-z 0-9 apostrophe ' dash - and space. 0-9 apostrophe ' dash - and space are optional, but it should not allow only these optional stuffs without any ...
LogicalDesk's user avatar
  • 1,257
0 votes
0 answers
103 views

how to show custom attribute message/badge in swagger

I have a .NET Web API, and I am using the Redoc library for Swagger display. When I use built-in Data Annotation attributes like 'Required', it shows a little red message in Redoc saying 'Required'. ...
Mohamad Hammash's user avatar
0 votes
0 answers
124 views

Regarding CVAT (Problem in store keypoints)

I hope everything is well with you. I have a critical question about CVAT. I'm working on detecting keypoints and labeling a custom dataset. However, when I export the dataset after labeling with COCO ...
Asifuzzaman Jishan's user avatar
0 votes
1 answer
157 views

How to handle data format for a DateTime field in the model for ASP.NET razor page with Arabic culture

While I set the Arabic language at that time my modifyOn/createOn date property throws an invalid state (for English it's working fine). if (model.isValid) returns false even when date is valid, but ...
Nalawala Murtaza's user avatar
1 vote
1 answer
385 views

MudBlazor:How to validate a list object in EditForm?

Here is my test code. It always pass to the "Send" Method when click the submit button even if have not inputted anything. @page "/ValidationTest"; @inject IDialogService ...
Iori Kyo's user avatar
0 votes
1 answer
281 views

Range and DataType attributes on double property not being triggered

I have a property in my page model of type double, is required and should be between a specific range. I'm also adding custom error messages. I have defined said property like this: [BindProperty] [...
Fernando Gómez's user avatar
0 votes
0 answers
16 views

How to train model on small data (100 labelised data)?

My company want to offer a new service of data analysis. They want to automatically categorize interview data in different classes (more than 5). But At the moment, only 100 are fully categorized. we ...
emma's user avatar
  • 193
1 vote
1 answer
702 views

How to get Json Property name in data annotation model validation results in .NET C#

I am validating Data Model using Data Annotations in .NET Core C#. Model: public class UserDetails { /// <summary> /// First name of user /// </summary> [Required(...
PavanKumar GVVS's user avatar
0 votes
0 answers
114 views

C# data validation attribute Greater than another parameter

I am looking for a way to ensure StartDate parameter is always lower than optional EndDate parameter. I know CompareAttribute does something similar where it verifies that two parameters are equal, ...
Luk164's user avatar
  • 667
1 vote
0 answers
131 views

Using MVC Client side Data Annotation validation

I am using MVC Data Annotation validation with a bootstrap 4 accordion. I want the MVC Data Annotation validation to kick in on the accordion using the AddRecommendation button but I can't get it to ...
Jefferson's user avatar
0 votes
0 answers
189 views

Product carousels email Annotation for Gmail promotions not working

I need to create Product carousels display multiple image previews for a promotion. I have used the below script (with values filled) and used it in my email template but not showing up any results. ...
Farzana Fathima's user avatar

1
2 3 4 5
61