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

Thumbs up or thumbs down on PHP

php if-statement

what i'm basically trying to do is make a 'thumbs up' appear if the user scores >= to 2 and shows a 'thumbs down' if the user scores < 2

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.