ValidateDateOccursAfter

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

Constructor(s):
  • public ValidateDateOccursAfterAttribute(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
    }

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


Valid Entity:
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 6, 2006 at 9:28 PM by Arcware, version 5

Comments

No comments yet.