Files

24 lines
857 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
namespace ArgumentsToolkit;
/// <summary>
/// Базовый атрибут для всех правил валидации.
/// </summary>
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public abstract class ValidationAttribute : Attribute
{
/// <summary>Кастомное сообщение об ошибке.</summary>
public abstract string ErrorTemplate { get; set; }
/// <summary>
/// Проверяет значение свойства.
/// </summary>
/// <param name="value">Значение свойства.</param>
public abstract bool Validate(object? value);
/// <summary>
/// Возвращает сообщение об ошибке для указанного значения.
/// </summary>
public abstract string GetErrorMessage(string optionName, object? value);
}