TimeSpanRangeAttribute
Ecng.ComponentModel
Validates that a TimeSpan value is within the specified range (inclusive).
继承自: RangeAttribute
实现: IValidator
构造函数
TimeSpanRangeAttribute
public TimeSpanRangeAttribute(TimeSpan minimum, TimeSpan maximum)
timeSpanRangeAttribute = TimeSpanRangeAttribute(minimum, maximum)
Creates a new instance of TimeSpanRangeAttribute.
- minimum
- Minimum value (inclusive).
- maximum
- Maximum value (inclusive).
TimeSpanRangeAttribute
public TimeSpanRangeAttribute(string minimum, string maximum)
timeSpanRangeAttribute = TimeSpanRangeAttribute(minimum, maximum)
Creates a new instance of TimeSpanRangeAttribute using string constants suitable for attribute usage.
- minimum
- Minimum value (inclusive), e.g. "00:00:00".
- maximum
- Maximum value (inclusive), e.g. "00:00:02".
属性
DisableNullCheck
public bool DisableNullCheck { get; set; }
value = timeSpanRangeAttribute.DisableNullCheck
timeSpanRangeAttribute.DisableNullCheck = value
Gets or sets a value indicating whether null checks should be disabled.
MaximumTs
public TimeSpan MaximumTs { get; }
value = timeSpanRangeAttribute.MaximumTs
Maximum value (inclusive).
MinimumTs
public TimeSpan MinimumTs { get; }
value = timeSpanRangeAttribute.MinimumTs
Minimum value (inclusive).
方法
IsValid
public override bool IsValid(object value)
result = timeSpanRangeAttribute.IsValid(value)
Validates the specified value by converting it and applying the custom validation.
- value
- The value to validate.
返回值: True if the value is valid; otherwise, false.