I have a class like this :
[CustomValidation(typeof(Validate_Class_MetaData), "Validate")]
public class tbl_MetaData
{
[Required(ErrorMessage = "-...")]
[Range(1, Int64.MaxValue, ErrorMessage = "-...")]
public global::System.Int64 Id { set; get; }
...
}
and I want validate my class using another class:
public class Validate_Class_MetaData
{
public static ValidationResult Validate (tblData tbl, ValidationContext vc)
{
the problem is I Have some warnings with errors.I mean some business rules not errors and I want show to user that warings using a dialog box and if user want save records with that warnings. Now I cant return complex object using ValidationResult.
How I can return ValidationResult.Success and some warnings together?
thanks
Unfortunately, the the ValidationResult class only supports either success or failure. From the link (emphasis is mine):
You could implement your own warnings by using a dedicated warnings element and adding text to it, for example, but ValidationResult does not support messages or warnings.