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...
|
| override? ValidationResult | IsValid (object? value, ValidationContext validationContext) |
| |
|
| 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.
|
| |
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).
◆ RequiredWhenAttribute()
| OFT.Attributes.RequiredWhenAttribute.RequiredWhenAttribute |
( |
string |
propertyName, |
|
|
params object[] |
values |
|
) |
| |
- Parameters
-
| propertyName | Name of the source property whose value controls the required state. |
| values | Values of the source property for which this property is required. |
◆ IsValid()
| override? ValidationResult OFT.Attributes.RequiredWhenAttribute.IsValid |
( |
object? |
value, |
|
|
ValidationContext |
validationContext |
|
) |
| |
|
protected |
◆ 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: