Class MaxItemsValidationRule
Validates whether collection satisfies the MaxItems limit.
public sealed class MaxItemsValidationRule : ValidationRule<MaxItemsValidationRuleProperties, MaxItemsValidationRuleClientProperties, IEnumerable>, IValidationRule
- Inheritance
-
objectValidationRule<MaxItemsValidationRuleProperties, MaxItemsValidationRuleClientProperties, IEnumerable>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
ILocalizationServiceLocalization 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
MaxItemsValidationRuleClientPropertiesCurrent 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
IEnumerableValue to be validated.
formFieldValueProvider
IFormFieldValueProviderProvider of values of other form fields for contextual validation.
Returns
- Task<ValidationResult>
Returns the validation result.
Remarks
Null value is treated as empty collection.