-
Notifications
You must be signed in to change notification settings - Fork 2
/
ValidationException.cs
31 lines (27 loc) · 1.06 KB
/
ValidationException.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Agero.Core.Checker;
using Agero.Core.Validator.Helpers;
using System;
using System.Collections.Generic;
namespace Agero.Core.Validator
{
/// <summary>Validation exception for particular untyped object.</summary>
public class ValidationException : Exception, IValidationErrors
{
/// <summary>Constructor</summary>
/// <param name="obj">Untyped object.</param>
/// <param name="errors">Validation errors.</param>
public ValidationException(object obj, IReadOnlyCollection<ValidationError> errors)
: base(ExceptionMessageFormatter.CreateExceptionMessage(obj, errors))
{
Check.ArgumentIsNull(obj, "obj");
Check.ArgumentIsNull(errors, "errors");
Check.Argument(errors.Count > 0, "errors.Count > 0");
Object = obj;
Errors = errors;
}
/// <summary>Untyped object.</summary>
public object Object { get; }
/// <summary>Validation errors.</summary>
public IReadOnlyCollection<ValidationError> Errors { get; }
}
}