Table of Contents

Class MaxItemsValidationRule

Namespace
Kentico.Xperience.Admin.Base.Forms
Assembly
Kentico.Xperience.Admin.Base.dll

Validates whether collection satisfies the MaxItems limit.

public sealed class MaxItemsValidationRule : ValidationRule<MaxItemsValidationRuleProperties, MaxItemsValidationRuleClientProperties, IEnumerable>, IValidationRule
Inheritance
object
MaxItemsValidationRule
Implements
Inherited Members
Extension Methods

Constructors

MaxItemsValidationRule(Func<IEnumerable>, ILocalizationService)

Creates a new instance of MaxItemsValidationRule class.

public MaxItemsValidationRule(Func<IEnumerable> valueProvider, ILocalizationService localizationService)

Parameters

valueProvider Func<IEnumerable>

Delegate to provide value.

localizationService ILocalizationService

Localization service.

Properties

ClientRuleName

Gets the client rule name identifier.

public override string ClientRuleName { get; }

Property Value

string

DefaultErrorMessage

Defines default error message of the validation rule.

protected override string DefaultErrorMessage { get; }

Property Value

string

Methods

ConfigureClientProperties(MaxItemsValidationRuleClientProperties)

Allows set validation rule client properties.

protected override Task ConfigureClientProperties(MaxItemsValidationRuleClientProperties clientProperties)

Parameters

clientProperties MaxItemsValidationRuleClientProperties

Current instance of client properties.

Returns

Task

Validate(IEnumerable, IFormFieldValueProvider)

Validates whether value's item count is less than or equal to MaxItems.

public override Task<ValidationResult> Validate(IEnumerable value, IFormFieldValueProvider formFieldValueProvider)

Parameters

value IEnumerable

Value to be validated.

formFieldValueProvider IFormFieldValueProvider

Provider of values of other form fields for contextual validation.

Returns

Task<ValidationResult>

Returns the validation result.

Remarks

Null value is treated as empty collection.