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
0
votes
0 answers

Returning back the same view (dialog box, tabs etc) after ModelState is invalid in ASP .NET MVC

Fresh ASP-MVC'er here. My Model: Applications.cs, has a required string field: name. MainView, showApps, shows all the apps in the DB in a table ... cleaned out code: @foreach (var app in Model) { // javascript code below that…
MAR
  • 95
  • 2
  • 7
0
votes
1 answer

ASP.NET MVC 2: passing model, prevent validation on second page

This is my setup: Model => View1 => Validate Model Model => View2 => I need to ignore Validation and just pass the Model ViewData from Model => View3 As you can see, I'm trying to pass my Model from View to View. However, it's causing my problems…
dcolumbus
  • 9,596
  • 26
  • 100
  • 165
0
votes
2 answers

C# Numeric Nullable fields Validation

i do have 2 fields in the front end and i do perform model station validation [Required] Public decimal? NetPay { get; set; } [Required] Public decimal? Tax { get; set; } if i type some string value in one of the fields in the front end the value…
Anonymous
  • 1
  • 1
0
votes
1 answer

ModelValidation on posted action parameter not happening

Why doesn't ASP.NET Core validate [FromBody] attributed action parameters? In the example below the paramter value of type SomeClass does not get validated. It doesn't even appear in the ModelState dictionary (only id). this.ModelState.IsValid is…
MarcusK
  • 194
  • 1
  • 11
0
votes
1 answer

Rails 5 - Validate model attribute equals one of 3 defined strings

Still newish to Rails, so apologies, I've been looking online and can't seem to find something that works. I have an application where a guest can RSVP to an event. On creation of the guest I'm defaulting the :rsvp attribute to 'Awaiting RSVP'. I…
0
votes
1 answer

Why is this validates_inclusion_of integer within range failing?

I am trying to validate on the model that my salary attr, an integer value, fits within a range, despite the value indeed fitting within that range, it fails with salary: ["is not included in the list"], any ideas what I'm…
jbk
  • 1,911
  • 19
  • 36
0
votes
2 answers

model showing invalid even after it contain values

I have a model in mvc as below public class person { [Required(ErrorMessage = "Please enter First Name.")] public string first_name {get;set;} [Required(ErrorMessage = "Please enter last Name")] public string last_name {get;set;} …
Sachu
  • 7,555
  • 7
  • 55
  • 94
0
votes
1 answer

@Scripts doesn't exist in Asp.Net MVC

I'm trying to add Model validation in Asp.Net MVC , So I need to import the libraries at first inside Views\Share_Layout.cshtml . Then it kills me in a second. @Scripts doesn't exist What is going on ? If some further information needed , please…
OOD Waterball
  • 707
  • 1
  • 11
  • 31
0
votes
2 answers

Custom validation rules for ASP.NET MVC2 Application

I am attempting to add validation to my application. I have some rules I need to check before allowing the information to be written to the database. I have the basic data validation added to the model, but I also need to make sure that if one field…
Mike Wills
  • 20,959
  • 28
  • 93
  • 149
0
votes
1 answer

The difference in roc_auc_score?

I just wanna clarify that what is the difference between roc_auc_score(y_test,results.predict(X_test)) and roc_auc_score(y_test,results.predict_proba(X_test)[:,1]) I know the latter one return the probability of class 0 for each test observation…
LUSAQX
  • 377
  • 2
  • 6
  • 19
0
votes
1 answer

Cross Validation with ROC?

I use the code to run cross validation, returning ROC scores. rf = RandomForestClassifier(n_estimators=1000,oob_score=True,class_weight = 'balanced') scores = cross_val_score ( rf, X,np.ravel(y), cv=10, scoring='roc_auc') How can I return the…
LUSAQX
  • 377
  • 2
  • 6
  • 19
0
votes
1 answer

Validate required model only

I'm using two models, Login & Signup Model in a View. public class Login { [Required(ErrorMessage ="User ID Required.")] public string UserID { get; set; } [Required(ErrorMessage ="Password Required")] public string Password { get;…
0
votes
0 answers

C# ASP NET MVC 5.0 Postback goes to Html.RenderPartial() on View Model Validation Error

I have an unexpected post back to a Html.RenderPartial() action when the main page fails model data validation. If there are no errors with model validation the page posts back to the expected controller action. Has anyone run into this and what…
0
votes
1 answer

Validate model using data annotation when doing AJAX call on form submission

I have a problem with jquery ajax call on form submission. As I don't want my page to be refreshed when submitting a form, I do e.preventDefault() Unfortunately this causes all the client side model data annotation validation not to be displayed. It…
Grentley
  • 315
  • 3
  • 6
  • 19
0
votes
0 answers

ASP.NET MVC disabling client side/server side validaiton on all fields in a complex obect

I have the following classes: public class Person { public PhoneContact PreferredContact { get; set; } public PhoneContact SecondaryContact { get; set; } public string Email { get; set; } } public class PhoneContact { …