ValidateMaxCount

Description: Indicates a collection has a maximum count.

Constructor(s):
  • public ValidateMaxCountAttribute(int maxCount, string message)

Parameters:
  • maxCount: The maximum count of the collection.
  • message: The message to be used if validation fails.

Example Usage:
public class MyEntity : EvilBaseEntity
{
    [ValidateMaxCount(3, "Collection1 must not contain more than 3 items.")]
    public List<string> Collection1
    {
        // Omitted for brevity
    }
}


Valid Entity 1:
MyEntity entity = new MyEntity();
entity.Collection1.Add("Item1");
entity.Collection1.Add("Item2");
entity.Collection1.Add("Item3");

bool result = entity.IsValid();


Valid Entity 2:
MyEntity entity = new MyEntity();
entity.Collection1.Add("Item1");
entity.Collection1.Add("Item2");

bool result = entity.IsValid();


Invalid Entity:
MyEntity entity = new MyEntity();
entity.Collection1.Add("Item1");
entity.Collection1.Add("Item2");
entity.Collection1.Add("Item3");
entity.Collection1.Add("Item4");

bool result = entity.IsValid();


Last edited Dec 20, 2006 at 1:18 PM by Arcware, version 1

Comments

No comments yet.