return a complex object instead of ValidationResult in CustomValidation

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

Answers


Unfortunately, the the ValidationResult class only supports either success or failure. From the link (emphasis is mine):

If the value of the member successfully validates, the returned ValidationResult object equals the value of the Success field. To determine whether validation succeeded, you should check whether the returned object equals Success. If the value of the member does not validate, the returned ValidationResult object contains an error message and a collection of member names for the validation error, if they can be retrieved.

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.


Need Your Help

Getting question marks (???) instead of text when inserting Greek into Excel Spreadsheet using as3xls library for Flash

excel actionscript-3 utf-8 as3xls

I'm trying to collate some xliff translation files into an XLS file using the as3xls library in my AIR application. I can successfully load, parse, and compose all the data into a document, except...

Calling private function from laravel controller

php laravel laravel-4

I'm trying to extract some code to a private function inside a controller in order to tidy it up a bit, but the function seems not to run.