Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 1e07b015 authored by Markus QUARITSCH's avatar Markus QUARITSCH
Browse files

extend validation to check for null-object

parent 1f5738ad
No related branches found
No related tags found
No related merge requests found
......@@ -54,6 +54,8 @@ namespace TUGraz.VectoCommon.Utils
/// <returns>Null, if the validation was successfull. Otherwise a list of ValidationResults with the ErrorMessages.</returns>
public static IList<ValidationResult> Validate<T>(this T entity, ExecutionMode mode)
{
if (entity == null)
return new[] { new ValidationResult(string.Format("null value given for {0}", typeof(T)))};
var context = new ValidationContext(entity);
context.ServiceContainer.AddService(typeof(ExecutionMode), new ExecutionModeServiceContainer(mode));
var results = new List<ValidationResult>();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment