API Reference: MaxCountAttribute Class

The MaxCountAttribute can be applied to collection-based content model properties. The attribute sets the maximum number of items that can be added to the property value in the back office application.

You can combine this attribute with the MinCount attribute to specify a min/max range.


Decorate the model property with the MaxCountAttribute. Pass the maximum allowed number of items in the attribute constructor.

The attribute can only be applied to collection-based properties (i.e. IList<T>, ICollection<T>, etc.). An exception will be thrown if the attribute is applied to a non-collection-based property.


The following example specifies a maximum count of 5 items for the PageLinks property (as well as a minimum count of 2).

public class SampleContent: IContentType
    public IReadOnlyList<Link> PageLinks { get; set; }

    // ...