3,032 questions
0
votes
0
answers
71
views
How to return data annotations error message in one string?
I'm using data annotations from System.ComponentModel.DataAnnotations in my ASP.NET project. I get an error message where you can describe the requirements such as "Name is required" and etc....
1
vote
1
answer
66
views
How do I define a C# / ASP.NET MVC String class with a MaxLength that works with Entity Framework Core?
I would like to define a class for different strings which Entity Framework Core will recognise and apply certain rules without data annotations.
For instance I would like to replace the following ...
2
votes
0
answers
97
views
Validation and the required modifier
I'm working on an ASP.NET Core Minimal API. We are using the MiniValidation library for request validation on our endpoints. We have some strict linting that means for reference types we need to ...
0
votes
1
answer
68
views
Custom Data Annotations Validator doesn't display ErrorMessage
Here's my custom validator:
public class CustomRuleFileTypeAttribute : ValidationAttribute
{
protected override ValidationResult IsValid(object value,ValidationContext validationContext)
...
0
votes
1
answer
54
views
DataAnnotations validation messages still in English after setting pt-BR culture
I'm trying to get data annotations validation messages in Portuguese (pt-BR) but they remain in English even after setting the culture.
Here's what I've tried - in Program.cs:
var builder = ...
0
votes
1
answer
58
views
EF .NET 6 Data Annotations with database-first: cannot make annotations work
Here's a model class (generated by scaffolding, nothing changed):
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
namespace ...
1
vote
1
answer
126
views
Blazor Validation Loop
I have a simple model called FooModel that has a single string property called Text.
I am attempting to use DataAnnotationsValidator to validate a collection of Models that are dynamically added to ...
0
votes
1
answer
81
views
How to combine 3 annotated datasets into one file for further processing?
I have a dataset annotated by three people, so now I have three files. This dataset is about tweets annotation. How can I combine this dataset into one file for further processing. The data set is an ...
0
votes
1
answer
275
views
Data annotations is not working as expected even after applying required attribute
I have a model class in .NET 6.0 and applied data annotations. I have extension class ApiRequestValidation that returns validationresults after checking the JSON in the request body.
using System....
0
votes
0
answers
86
views
Validation of string in list of string via regex in data annotation
I have a class Detail with a parameter of type List<string>
public class Detail
{
public int index { get; set; }
[MaxLength(50)]
[RegularExpressionList("^[a-zA-Z0-9א-ת@/\\.\\- !@...
0
votes
2
answers
839
views
ASP.NET Core 8 Web API data validation ignores data annotations
I'm trying to get automatic data validation working in an ApiController but when the user sends incorrect/missing data a JSON deserialization failed error message is returned instead of the custom ...
0
votes
1
answer
40
views
Validating multiple checkbox in ASP.NET MVC
I have 4 checkboxes in my form and want user to select at least one of the checkbox when form is submitted.
I am using ExpressiveAnnotations.Attributes; reference as we use this in other part of ...
0
votes
2
answers
41
views
StringLengthAttribute does not enforce length
I have a property with StringLength attribute, but I can assign a string of any length to this property. I created the following test program in VB.NET 4.7 Framework:
Imports System.ComponentModel....
0
votes
1
answer
589
views
ValidateOnStart() and [Required] don't seem to work
I have an appsettings.json with the following contents:
{
"Settings": {
"Greeting": "Hello World"
}
}
that I associate with
public sealed class ...
1
vote
2
answers
988
views
How can I get access to MaxLengthAttribute Class to obtain the LENGTH value of a field during validation?
In the handleSubmit-function of a Blazor CRUD component, I have to provide an error message that is based on the DataAnnotation MaxLength-attribute. I would like to show a "custom" C# error ...
0
votes
1
answer
168
views
how to DbContextBulkExtensions.BulkUpdate with ConcurrencyCheck
I have situation when I have 2 pods that getting requests to update status of object lets call him user, he have 3 statuses : new, verified and failed.
they getting in parallel the entity with status ...
0
votes
1
answer
141
views
How to change the annotation of data resulted by Yolov8?
I have a huge number of images that have human.
after a ran Yolov8 on them, all resulted labels are class 0 "person"
I want to change to 3 classes class 0 "man", class 1 "...
0
votes
1
answer
49
views
DbContext.OnModelCreating - Reading custom attribute for each DbSet
I have a IdSeqAttribute:
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public class IdSeq(string seq) : Attribute
{
public string Seq = seq;
}
and use it like ...
-2
votes
2
answers
96
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 ...
0
votes
1
answer
109
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 ...
0
votes
0
answers
84
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]
...
0
votes
0
answers
33
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 ...
3
votes
0
answers
887
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 ...
0
votes
0
answers
21
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 ...
0
votes
1
answer
569
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
{
...