108 lines
3.3 KiB
C#
108 lines
3.3 KiB
C#
using System;
|
||
using NodePipeline.Abstractions.Validators;
|
||
|
||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||
|
||
namespace NodePipeline.Abstractions.Attributes.Validation.NodeField;
|
||
|
||
//TODO: for analyzer: apply to NodeField<T>, value must be T type where T is integer number
|
||
[AttributeUsage(AttributeTargets.Property)]
|
||
public sealed class HasValueBetweenAttribute : Attribute
|
||
{
|
||
/// <summary>
|
||
/// Associated with <see cref="NumberRangeValidator{T}" />
|
||
/// </summary>
|
||
/// <param name="min">String min length non-inclusive</param>
|
||
/// <param name="max">String max length non-inclusive</param>
|
||
public HasValueBetweenAttribute(decimal min, decimal max)
|
||
{
|
||
Min = min;
|
||
Max = max;
|
||
}
|
||
|
||
/// <summary>
|
||
/// Associated with <see cref="NumberRangeValidator{T}" />
|
||
/// </summary>
|
||
/// <param name="min">String min length non-inclusive</param>
|
||
/// <param name="max">String max length non-inclusive</param>
|
||
public HasValueBetweenAttribute(int min, decimal max)
|
||
{
|
||
Min = min;
|
||
Max = max;
|
||
}
|
||
|
||
/// <summary>
|
||
/// Associated with <see cref="NumberRangeValidator{T}" />
|
||
/// </summary>
|
||
/// <param name="min">String min length non-inclusive</param>
|
||
/// <param name="max">String max length non-inclusive</param>
|
||
public HasValueBetweenAttribute(decimal min, int max)
|
||
{
|
||
Min = min;
|
||
Max = max;
|
||
}
|
||
|
||
/// <summary>
|
||
/// Associated with <see cref="NumberRangeValidator{T}" />
|
||
/// </summary>
|
||
/// <param name="min">String min length non-inclusive</param>
|
||
/// <param name="max">String max length non-inclusive</param>
|
||
public HasValueBetweenAttribute(int min, int max)
|
||
{
|
||
Min = min;
|
||
Max = max;
|
||
}
|
||
|
||
public decimal? Min { get; }
|
||
public decimal? Max { get; }
|
||
}
|
||
|
||
//применить к NodeField<T>, value должно быть типа T, где T – целые числа
|
||
[AttributeUsage(AttributeTargets.Property)]
|
||
public sealed class HasMinValueAttribute : Attribute
|
||
{
|
||
/// <summary>
|
||
/// Associated with <see cref="NumberRangeValidator{T}" />
|
||
/// </summary>
|
||
/// <param name="value">String min length non-inclusive</param>
|
||
public HasMinValueAttribute(decimal value)
|
||
{
|
||
Value = value;
|
||
}
|
||
|
||
/// <summary>
|
||
/// Associated with <see cref="NumberRangeValidator{T}" />
|
||
/// </summary>
|
||
/// <param name="value">String min length non-inclusive</param>
|
||
public HasMinValueAttribute(int value)
|
||
{
|
||
Value = value;
|
||
}
|
||
|
||
public decimal Value { get; }
|
||
}
|
||
|
||
//применить к NodeField<T>, value должно быть типа T, где T – целые числа
|
||
[AttributeUsage(AttributeTargets.Property)]
|
||
public sealed class HasMaxValueAttribute : Attribute
|
||
{
|
||
/// <summary>
|
||
/// Associated with <see cref="NumberRangeValidator{T}" />
|
||
/// </summary>
|
||
/// <param name="value">String max length non-inclusive</param>
|
||
public HasMaxValueAttribute(decimal value)
|
||
{
|
||
Value = value;
|
||
}
|
||
|
||
/// <summary>
|
||
/// Associated with <see cref="NumberRangeValidator{T}" />
|
||
/// </summary>
|
||
/// <param name="value">String max length non-inclusive</param>
|
||
public HasMaxValueAttribute(int value)
|
||
{
|
||
Value = value;
|
||
}
|
||
|
||
public decimal Value { get; }
|
||
} |