This project is read-only.

ValidateMinLength

Description: Indicates a property has a minimum length.

Constructor(s):
  • public ValidateMinLengthAttribute(int minLength, string message)

Parameters:
  • minLength: The minimum length of the property.
  • message: The message to be used if validation fails.

Example Usage:
public class MyEntity : EvilBaseEntity
{
    [ValidateMinLength(5, "Property1 has a minimum length of 5.")]
    public string Property1
    {
        // Omitted for brevity
    }
}


Valid Entity 1:
MyEntity entity = new MyEntity();
entity.Property1 = "abcde";

bool result = entity.IsValid();


Valid Entity 2:
MyEntity entity = new MyEntity();
entity.Property1 = "abcdefghijklmnopqrstuvwxyz";

bool result = entity.IsValid();


Invalid Entity 1:
MyEntity entity = new MyEntity();
entity.Property1 = "abc";

bool result = entity.IsValid();


Invalid Entity 2:
MyEntity entity = new MyEntity();
entity.Property1 = null;

bool result = entity.IsValid();


Invalid Entity 3:
MyEntity entity = new MyEntity();
entity.Property1 = string.Empty;

bool result = entity.IsValid();


Last edited Dec 7, 2006 at 3:47 PM by Arcware, version 1

Comments

No comments yet.