StepAttribute

Ecng.ComponentModel

Validates that a numeric value lies on a discrete grid defined by Base + n * Step.

继承自: ValidationAttribute

实现: IValidator

构造函数

StepAttribute
public StepAttribute(decimal step, decimal baseValue)
stepAttribute = StepAttribute(step, baseValue)

Creates new StepAttribute.

step
Positive step.
baseValue
Grid base (default 0).

属性

BaseValue
public decimal BaseValue { get; }
value = stepAttribute.BaseValue

Grid base.

DisableNullCheck
public bool DisableNullCheck { get; set; }
value = stepAttribute.DisableNullCheck
stepAttribute.DisableNullCheck = value

Allow null values.

Step
public decimal Step { get; }
value = stepAttribute.Step

Grid step.

方法

IsValid
public override bool IsValid(object value)
result = stepAttribute.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.