This project is read-only.

ValidateMinCount

Description: Indicates a collection has a minimum count.

Constructor(s):
  • public ValidateMinCountAttribute(int minCount, string message)

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

Example Usage:
public class MyEntity : EvilBaseEntity
{
    [ValidateMinCount(3, "Collection1 must contain at least 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");
entity.Collection1.Add("Item3");
entity.Collection1.Add("Item4");

bool result = entity.IsValid();


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

bool result = entity.IsValid();

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

Comments

No comments yet.