model-validation Questions

9

Solved

I have the following class: public class CreateJob { [Required] public int JobTypeId { get; set; } public string RequestedBy { get; set; } public JobTask[] TaskDescriptions { get; set; } } I...
Inflectional asked 13/11, 2012 at 13:25

3

Solved

Problem I know there is a lot of ways of doing Model validation within MVC, and there is quite a lot of documentation regarding this topic. However, I'm not quite sure what's the best approach for...

8

I have one text area field called Description in my view. I wish to increase the size of that field. My code <div class="col-sm-3"> <div class="form-group"> <span style="color: ...
Yeh asked 3/5, 2016 at 4:11

3

Solved

I have a controller where my PUT method uses multipart/form-data as content type and so I am getting the JSON and the mapped class thereby inside the controller. Is there a way I could validate th...
Maddox asked 3/11, 2016 at 10:57

8

Solved

I am trying to use Model Validation in MVC .Net Core and can't manage to replace this default error message 'The value '' is invalid'. In theory, we can replace our own custom error message by usi...
Kohima asked 7/4, 2017 at 15:1

3

Solved

I have a model where the property CompanyID allows a null value public partial class ReportTemplateItem { [Key] public int ReportTemplateItemID { get; set; } [Required] public int ReportTempla...
Subcritical asked 22/7, 2020 at 14:56

9

Solved

HTML5 provides for automatic URL validation :- <form> <input type="url" name="someUrl"> </form> This will fail validation for URL's that don't have a protocol prefix - e.g. st...
Crinkle asked 30/7, 2013 at 12:23

5

Solved

I am writing a unit test for a controller like this: public HttpResponseMessage PostLogin(LoginModel model) { if (!ModelState.IsValid) return new HttpResponseMessage(HttpStatusCode.BadRequest); ...

3

Solved

I am currently trying to write a Web API application where one of the parameters I'd like to validate is a query parameter (that is, I wish to pass it in in the form /route?offset=0&limit=100):...
Delilahdelimit asked 24/2, 2016 at 0:55

2

I just moved to ASP.NET Core 3.0 and it seems that either model validation with inheritance is broken, or I am missing something. When I post the following model with IlVal00 = null, it says: t...

2

Solved

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 ...
Guereza asked 3/5, 2020 at 14:45

3

I am using ASP.NET Core 2.0 default model validation and it seems not working with the ModelState.IsValid always true despite having wrong data in model. [HttpPost("abc")] public async Task<IAc...
Powys asked 11/8, 2018 at 11:16

11

Solved

I have a curious problem with ASP.NET MVC3 client-side validation. I have the following class: public class Instrument : BaseObject { public int Id { get; set; } [Required(ErrorMessage = "Name ...
Exceeding asked 23/7, 2011 at 16:10

1

I'm using automatic model validation (see "Better Input Processing") to keep my controllers clean; so: [HttpPost] [ProducesResponseType(typeof(Product), 201)] public IActionResult Post([FromBody] ...

2

I'm implementing a REST API project using ASP.NET Core MVC 2.0, and I'd like to return a 400 status code if model binding failed (because the request is syntactically wrong) and a 422 status code i...
Spada asked 29/8, 2017 at 14:6

2

Solved

I have a View (Index.cshtml) that it has two modals (Bootstrap modal). I have loaded a Partial View in each ‍‍‍modal. So in this View, I have two Partial Views(AddContractHistory.cshtml and AddCom...
Draughtboard asked 2/10, 2017 at 10:34

1

Solved

I have developed a custom validator Attribute class for checking Integer values in my model classes. But the problem is this class is not working. I have debugged my code but the breakpoint is not ...
Jovial asked 15/3, 2018 at 13:55

7

Solved

I have the following viewmodel definition public class AccessRequestViewModel { public Request Request { get; private set; } public SelectList Buildings { get; private set; } public List<Per...
Quartersaw asked 28/2, 2011 at 19:40

1

I have created a ModelBinder, which only gets triggered if an object has a [Decimal] attribute assigned, yet for some reason, despite it actually sanitising the data it does not seem to update the ...

3

Is there any default validation for MVC 5 where I can set min and max value of date? In my model i want date validation public class MyClass { [Required(ErrorMessage="Start date and time cann...
Step asked 14/2, 2014 at 10:54

0

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 ...
Extramundane asked 9/12, 2016 at 16:28

1

I successfully implemented FluentValidation in my WebApi project controller that only had one HttpGet method. When I added another HttpGet method, I added route attribute to both methods. i.e. [Rou...
Causey asked 28/4, 2016 at 19:55

4

Solved

I am storing the Azure blob url into my database.Can I get the blob by using that url? Actually I need to update the blob and while doing that I need validations. So I need to convert that database...
Chromosphere asked 1/11, 2013 at 8:57

3

Solved

I have a registration form and the user must enter the square footage of their house. I would like this value to be only an integer. Is there a way to validate this value using attributes asp.net m...
Bushmaster asked 23/8, 2010 at 14:5

1

Solved

I setup a web api project to use FluentValidation using the webapi integration package for FluentValidation. Then I created a validator that uses CustomAsync(...) to run queries against the databas...

© 2022 - 2024 — McMap. All rights reserved.