Class RequiredImageAttribute
Used to specify that one or more form factors should be required.
Inherited Members
Namespace: AdaptiveImages.Validation
Assembly: AdaptiveImages.dll
Syntax
[AttributeUsage(AttributeTargets.Property, Inherited = true)]
public class RequiredImageAttribute : ImageValidationAttribute
Constructors
RequiredImageAttribute()
Creates an attribute without any form factors specified.
Declaration
public RequiredImageAttribute()
Remarks
If no form factors are specified, all form factors are treated as required for AdaptiveImage properties.
RequiredImageAttribute(FormFactor)
Used to make one or more form factors required.
Declaration
public RequiredImageAttribute(FormFactor formFactor)
Parameters
Type | Name | Description |
---|---|---|
FormFactor | formFactor |
Remarks
Only applicable on AdaptiveImage properties. Form factor may not be specified if attribute is added to a SingleImage property.
Properties
AlternateText
Gets or sets whether the alternate text should be required, defaults to true.
Declaration
public bool AlternateText { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
Only applicable when images are set.
Images
Gets or sets whether images should be required, defaults to true.
Declaration
public bool Images { get; set; }
Property Value
Type | Description |
---|---|
bool |
Methods
IsValid(object?, ValidationContext)
Checks whether a SingleImage property has been set, or if one or more form factors of an AdaptiveImage have been set.
Declaration
protected override ValidationResult? IsValid(object? value, ValidationContext validationContext)
Parameters
Type | Name | Description |
---|---|---|
object | value | The property being validated. |
ValidationContext | validationContext | Context from which the property and its owner instance are resolved. |
Returns
Type | Description |
---|---|
ValidationResult |
Overrides
Exceptions
Type | Condition |
---|---|
NotSupportedException |