Passing Validation exceptions via WCF REST

When using WCF and Rest one thing you’re going to have to consider is the validation of the object, the way to do this is using the Validation Application Block included in the Microsoft Enterprise Library to validate the data transfer objects. This way you can decorate the objects with attributes to validated the objects

Here is an example

public static void Validate<T>(T obj)
     ValidationResults results = Validation.Validate(obj);

     if (!results.IsValid)
string[] errors = results
          .Select(r => r.Message)

     WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.BadRequest;
     WebOperationContext.Current.OutgoingResponse.StatusDescription = String.Concat(errors);

thanks to Enrico Campidoglio for helping out on this