Questions tagged [ivalidatableobject]

40 questions
2
votes
1 answer

IValidatableObject not working in mvc 4 web app

So I have web app that is registering users and business partners. This is how my models look like public class UserModel : IValidatableObject { //here are some properties and methods that I am using in Validate method public…
1
vote
3 answers

IValidatableObject Validate Method not working

I have this class used in MVC3... The Validation Attributes for each property are working as it should but when the Validate method is called and any results are returned it is not posting back to the form. Can anyone help?? public class Register :…
Andy Clark
  • 3,363
  • 7
  • 27
  • 42
1
vote
1 answer

IValidatableObject not triggered

I'm trying to make use of the IValidatableObject as described here http://davidhayden.com/blog/dave/archive/2010/12/31/ASPNETMVC3ValidationIValidatableObject.aspx. But it just wont fire when I'm trying to validate, the ModelState.IsValid is always…
1
vote
1 answer

How to show error message using IValidatableObject in WPF?

I'm using IValidatableObject to validate my template in wpf. However, the error message is not returned to the interface. However, it is worth clarifying that validation works. The only problem is that the message is not displayed in the…
1
vote
2 answers

dependency injection into view model class in asp.net core

I am using the following DTO class in one of my api controller class, in an asp.net core application. public class InviteNewUserDto: IValidatableObject { private readonly IClientRepository _clientRepository; public…
1
vote
1 answer

Validating ViewModel extended from POCO using IValidatableObject

Imagine User class. This class provides the only properties which are used in the database. public class User { public string Login { get; set; } public string Password { get; set; } public DateTime ActiveDateStart { get; set; } …
acelot
  • 752
  • 2
  • 7
  • 26
1
vote
1 answer

IValidatableObject Context

I am using IValidatableObject/Validator to validate my mvc models. So I have something like this public class Parent { public Child Child { get; set; } } public class Child { [Required] public string Name { get; set; } } So if I run a…
Pintac
  • 1,565
  • 3
  • 21
  • 38
1
vote
1 answer

How to access User.Identity from Validate method of IValidatableObject?

I have ViewModel which inherits from IValidatableObject. In this model I have to make custom validation and it's require Session variables and User.Identity. I could not find appropriate way how to access this variables. I thought something about…
Yara
  • 4,441
  • 6
  • 42
  • 62
1
vote
0 answers

Validating Uploaded Files Using IValidatableObject

Hi All! I'm a bit of a noob at model validation and i've been trying to validate an Articles object and an uploaded file using the IValidatableObject interface with no success. This following class validates the Articles object just fine but I…
Hemslingo
  • 272
  • 3
  • 11
0
votes
1 answer

Form Submission with two buttons

I am using Razor Pages. I have a form that allows you to either buy or sell. I need to change a value of the OrderType field in the OrderPlacement model, depending on whether the user buys or sells. I accomplish this using javascript.
HoboJeff
  • 101
  • 1
  • 1
  • 8
0
votes
1 answer

Devise does not valdiate email while sign_up

I have a model, User: class User < ActiveRecord::Base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :trackable include DeviseTokenAuth::Concerns::User extend EncryptedField validates…
0
votes
1 answer

ASP.NET Core - Validate that only one parameter is specified in contract

I have the following contract: public class UpdateUserRequest { public string Id { get; set; } public string Email { get; set; } public string AccountId { get; set; } } I want to validate that only one update property of the three is…
user17365408
0
votes
0 answers

IValidatableObject not firing upon form submission

I'm new to .net and am attempting to write some slick custom validation for a CustomerInfo form that I'm submitting. To do this, I'm implementing IValidatableObject on the model class and following this template from microsoft's…
neanderslob
  • 2,633
  • 6
  • 40
  • 82
0
votes
1 answer

Guarantee dto property to certain values both for incoming request to controller and value setting

I have a dto with a property where I only want to accept certain values, say ”Ready” or ”Started” and nothing else. I try to hinder any other values of being assigned to the property by placing some ”validation” inside the set-method, such as public…
0
votes
1 answer

MVC3 IValidatableObject Date

I have a basic form which has a date field and I want to validate it inside the IValidatableObject. The type of the field is mapped to a DateTime property so if someone types in 26/15/2011, how do you pick that up in the Validate method? Strictly…
fes
  • 2,465
  • 11
  • 40
  • 56