generated from Avanade/avanade-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathIValidatorExT.cs
32 lines (28 loc) · 1.45 KB
/
IValidatorExT.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
32
// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/CoreEx
using System;
using System.Threading;
using System.Threading.Tasks;
namespace CoreEx.Validation
{
/// <summary>
/// Extends the <see cref="IValidator{T}"/>
/// </summary>
/// <typeparam name="T">The value <see cref="Type"/>.</typeparam>
public interface IValidatorEx<T> : IValidatorEx, IValidator<T>
{
/// <inheritdoc/>
async Task<IValidationContext> IValidatorEx.ValidateAsync(object value, ValidationArgs? args, CancellationToken cancellationToken)
=> await ValidateAsync((T)value!, args, cancellationToken).ConfigureAwait(false);
/// <inheritdoc/>
async Task<IValidationResult<T>> IValidator<T>.ValidateAsync(T value, CancellationToken cancellationToken)
=> await ValidateAsync(value, null, cancellationToken).ConfigureAwait(false);
/// <summary>
/// Validate the entity value with specified <see cref="ValidationArgs"/>.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="args">An optional <see cref="ValidationArgs"/>.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
/// <returns>The resulting <see cref="ValidationContext{TEntity}"/>.</returns>
Task<ValidationContext<T>> ValidateAsync(T value, ValidationArgs? args, CancellationToken cancellationToken);
}
}