mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
27 lines
877 B
C#
27 lines
877 B
C#
namespace CliFx.Extensibility;
|
|
|
|
/// <summary>
|
|
/// Defines custom validation logic for activated command inputs.
|
|
/// </summary>
|
|
public abstract class BindingValidator<T> : IBindingValidator
|
|
{
|
|
/// <summary>
|
|
/// Returns a successful validation result.
|
|
/// </summary>
|
|
protected BindingValidationError? Ok() => null;
|
|
|
|
/// <summary>
|
|
/// Returns a non-successful validation result.
|
|
/// </summary>
|
|
protected BindingValidationError Error(string message) => new(message);
|
|
|
|
/// <inheritdoc cref="IBindingValidator.Validate" />
|
|
/// <remarks>
|
|
/// You can use the utility methods <see cref="Ok" /> and <see cref="Error" /> to
|
|
/// create an appropriate result.
|
|
/// </remarks>
|
|
public abstract BindingValidationError? Validate(T? value);
|
|
|
|
BindingValidationError? IBindingValidator.Validate(object? value) => Validate((T?)value);
|
|
}
|