ValidateDateOccursOnOrAfter

Description: Indicates a DateTime property occurs on or after another DateTime property.

Constructor(s):
  • public ValidateDateOccursOnOrAfterAttribute(string propertyName, string message)

Parameters:
  • propertyName: The name of the DateTime property to compare.
  • message: The message to be used if validation fails.

Example Usage:
public class MyEntity : EvilBaseEntity
{
    public DateTime DateTime1
    {
        // Omitted for brevity
    }

    [ValidateDateOccursOnOrAfter("DateTime1", "DateTime2 must be on or after DateTime1.")]
    public DateTime DateTime2
    {
        // Omitted for brevity
    }
}


Valid Entity 1:
MyEntity entity = new MyEntity();
entity.DateTime1 = DateTime.Today;
entity.DateTime2 = DateTime.Today;

bool result = entity.IsValid();


Valid Entity 2:
MyEntity entity = new MyEntity();
entity.DateTime1 = DateTime.Today;
entity.DateTime2 = DateTime.Today.AddDays(1);

bool result = entity.IsValid();


Invalid Entity:
MyEntity entity = new MyEntity();
entity.DateTime1 = DateTime.Today;
entity.DateTime2 = DateTime.Today.AddDays(-1);

bool result = entity.IsValid();

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

Comments

No comments yet.