/// <summary> /// Validate the object. /// </summary> /// <exception cref="ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (Code == null) { throw new ValidationException(ValidationRules.CannotBeNull, "Code"); } if (Message == null) { throw new ValidationException(ValidationRules.CannotBeNull, "Message"); } if (Details != null) { foreach (var element in Details) { if (element != null) { element.Validate(); } } } if (Innererror != null) { Innererror.Validate(); } }