Loading...
Searching...
No Matches
OFT.Attributes.RequiredWhenAttribute Class Reference

Behaves like RequiredAttribute, but only while the specified source property's value matches one of the provided values; otherwise the property is always considered valid. Derives from RequiredAttribute so it is enforced even by validators that run required-only checks (e.g. Validator.TryValidateObject with validateAllProperties: false). More...

Inheritance diagram for OFT.Attributes.RequiredWhenAttribute:
[legend]
Collaboration diagram for OFT.Attributes.RequiredWhenAttribute:
[legend]

Public Member Functions

 RequiredWhenAttribute (string propertyName, params object[] values)
 

Protected Member Functions

override? ValidationResult IsValid (object? value, ValidationContext validationContext)
 

Properties

string PropertyName [get]
 Name of the source property whose value determines whether this property is required.
 
object[] Values [get]
 The set of source property values for which this property is required.
 

Detailed Description

Behaves like RequiredAttribute, but only while the specified source property's value matches one of the provided values; otherwise the property is always considered valid. Derives from RequiredAttribute so it is enforced even by validators that run required-only checks (e.g. Validator.TryValidateObject with validateAllProperties: false).

Constructor & Destructor Documentation

◆ RequiredWhenAttribute()

OFT.Attributes.RequiredWhenAttribute.RequiredWhenAttribute ( string  propertyName,
params object[]  values 
)
Parameters
propertyNameName of the source property whose value controls the required state.
valuesValues of the source property for which this property is required.

Member Function Documentation

◆ IsValid()

override? ValidationResult OFT.Attributes.RequiredWhenAttribute.IsValid ( object?  value,
ValidationContext  validationContext 
)
protected

Property Documentation

◆ PropertyName

string OFT.Attributes.RequiredWhenAttribute.PropertyName
get

Name of the source property whose value determines whether this property is required.

◆ Values

object [] OFT.Attributes.RequiredWhenAttribute.Values
get

The set of source property values for which this property is required.


The documentation for this class was generated from the following file: