ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

GetMessages

Return all messages after call Validate method on Microsoft EnterpriseLibrary Validation Block

Source

public static string GetMessages(this ValidationResults value)
{
    return string.Join(
        Environment.NewLine, 
        value
        .OrderBy(item => item.Message)
        .Select(item => item.Message)
        .ToArray());
}

Example

MyObject target = new MyObject();
ValidationResults result = Validation.Validate<MyObject>(target);
string validationMessages = result.GetMessages();

Author: Alvaro Torres Tatis

Submitted on: 17 feb. 2012

Language: C#

Type: Microsoft.Practices.EnterpriseLibrary.Validation.ValidationResults

Views: 4699