Questions tagged [model-validation]

Model Validation is ASP.NET MVC validation method for your models with property attributes. Model validation works for client and server side validation.

For further information you can check Scott Gu's blog post: http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx

There is a expansion called "DATA ANNOTATIONS EXTENSIONS" for other custom validation types such as CreditCard, min-max integer value etc. http://weblogs.asp.net/srkirkland/archive/2011/02/23/introducing-data-annotations-extensions.aspx

325 questions
3
votes
1 answer

Should I use evaluate_generator or evaluate to evaluate my CNN model

I am implementing a CNN using keras to perform image classification and I had used .fit_generator() method to train the model till a stop condition is verified I used the next code: history_3conv = cnn3.fit_generator(train_data,steps_per_epoch =…
baddy
  • 369
  • 1
  • 3
  • 23
3
votes
1 answer

`[FromQuery]` IEnumerable parsing in ASP.NET Core 3.1?

So, when I tested how binding works for an IEnumerable argument, you simply pass the argument's name in the query string, repeatedly, like this: ?a=item1&a=item2&a=item3... So, what must I write, if I have an argument of type…
3
votes
2 answers

blazor editform change events

I want to have an InputSelect in a blazor editform that is bound to a model value and also has an onchange event that changes other properties in the model based on the new value. binding to both @bind-Value and @onchange does not work (im guessing…
Paul
  • 693
  • 1
  • 10
  • 25
3
votes
1 answer

Django: Model Validation Error ManytoManyField

I get this error while running syncdb Can't seem to figure out the issue. Please help. Error: One or more models did not validate: store.business: Reverse query name for field 'logo' clashes with field 'ImageBank.business'. Add a related_name…
Eva611
  • 5,964
  • 8
  • 30
  • 38
3
votes
1 answer

How to validate json request body as valid json in asp.net core

In asp.net core 2.1, when a controller action is set as: [HttpPost] public JsonResult GetAnswer(SampleModel question) { return Json(question.Answer); } where the SampleModel is defined as: public class…
Zaak
  • 482
  • 11
  • 25
3
votes
2 answers

EF Core not raising ValidationException

I have a base DbContext class like public abstract class DbContextBase : DbContext { public DbContextBase() { } public DbContextBase(DbContextOptions options) : base(options) { } public override int…
kovac
  • 4,945
  • 9
  • 47
  • 90
3
votes
3 answers

ASP.NET Core custom validation creates new instance of model

I'm playing with ASP.NET Core and trying to come up with a UI for a simple word game. You receive a randomly generated long word, and you're expected to submit shorter words from letters provided by the long word. The application doesn't use a…
Jura Gorohovsky
  • 9,886
  • 40
  • 46
3
votes
1 answer

How to stop validation after first error in ASP.NET Core 2.1

I know this question is asked several times for other frameworks and languages but I wanted to know how can I really stop my model validation once it gets the first error in ASP.NET Core 2.1? [Required(ErrorMessage =…
Suleman
  • 644
  • 3
  • 12
  • 23
3
votes
0 answers

IValidatableObject not validating if child collection is Invalid

I have an View Model that is an IValidatableObject that contains a collection of CustomFields that are also IValidatableObject. Both the view model and the custom fields have custom logic to check if they are valid when posted. The View Model looks…
Valuator
  • 3,262
  • 2
  • 29
  • 53
3
votes
0 answers

Model Validation is not working in ASP.NET Core 2.0

I have been developing a Web API with ASP.NET Core 2.0 framework. To validate the model, I have used data annotation attributes. There is also a Filter class which executes for validating the models in request pipeline. This filter class works fine…
3
votes
2 answers

Model State Validation in ASP.NET WEBAPI Core

I am trying to use model validation in ASP.NET WEBAPI Core. Below mentioned is the code from my model. [Range(typeof(decimal), "1.0", "90.1")] public decimal price{ get; set; } My understanding is, if I pass any value which is not in between 1.0 -…
Ane
  • 115
  • 9
3
votes
1 answer

Phone validation attribute not working

I'm trying to validate some user contact details like so: public class Customer { [Display(Name = "Your e-mail :")] [Required(ErrorMessage = "An email address is required")] [EmailAddress(ErrorMessage = "Invalid Email Address")] …
user602095
3
votes
2 answers

C# MVC Model Validation Timing

We have a model that is being displayed in a form on a partial view with model validations. We have a few fields like this: [Required(ErrorMessage = "{0} cannot be empty")] public string FirstName { get; set; } [Required(ErrorMessage = "{0} cannot…
Evan Frisch
  • 1,334
  • 5
  • 22
  • 40
3
votes
0 answers

Create a complex type model validation attribute with server and client validation

I'm trying to create an attribute that can validate a complex type both on the server and client side. This attribute will be used for required and non required complex types such as the following Address Class public partial class…
3
votes
1 answer

Why and how to fix ASP MVC model validation for child entities is called but not for parent entity?

I am using IValidatableObject validation for entities with e.g. following code: public class OuterObj : IValidatableObject { public int ID { get; set; } public string Name { get; set; } public IEnumerable InnerObjList {…