Table of Contents

Class ComparableValidationAttribute<T>

Namespace
Ecng.ComponentModel
Assembly
Ecng.ComponentModel.dll

Provides a base class for validation attributes that compare values of a struct type.

public abstract class ComparableValidationAttribute<T> : ValidationAttribute, IValidator where T : struct, IComparable<T>

Type Parameters

T

The type of value to compare. Must be a struct implementing IComparable<T>.

Inheritance
ComparableValidationAttribute<T>
Implements
Derived
Inherited Members
Extension Methods

Constructors

ComparableValidationAttribute()

protected ComparableValidationAttribute()

Properties

DisableNullCheck

Gets or sets a value indicating whether to disable the null check. When set to true, null values bypass validation.

public bool DisableNullCheck { get; set; }

Property Value

bool

Methods

IsValid(object)

Validates the specified value by converting it and applying the custom validation.

public override bool IsValid(object value)

Parameters

value object

The value to validate.

Returns

bool

True if the value is valid; otherwise, false.

Validate(T?, bool)

Validates the given nullable value using a custom rule.

protected abstract bool Validate(T? value, bool disableNullCheck)

Parameters

value T?

The nullable value to validate.

disableNullCheck bool

A flag indicating whether null check should be disabled.

Returns

bool

True if the value passes the validation rule; otherwise, false.