Hi,
I've tried to search for similar problems but can not find anything, however I think that the problem is typical.
I've entity with non-nullable field in it let's say Customer.Name: varchar(50) not null.
I've an application that just sets this field with a value in a text box. I'd like to enforce validation for this field so it is required(user should specify something before saving it).
I'm trying to use IDataErrorInfo for this purpose.
So basically I've a code like this:
customer.Name = ""
I assume that if the field is not null, valid values for it are everything except DbNull, String.Empty, or any string including only white characters.
Currently these values String.Empty, or any string including only white characters(not sure about DbNull) are valid values and do not add errors into IDataErrorInfo for that field.
What is the best way to add such validation? As you understand there are a lot of entities with the same fields(Products, Categories and so on), so solution should be general.
Thanks,
Anton