This project is read-only.

ValidateDateOccursOnOrBefore

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

Constructor(s):
  • public ValidateDateOccursOnOrBeforeAttribute(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
{
    [ValidateDateOccursOnOrBefore("DateTime2", "DateTime1 must be on or before DateTime2.")]
    public DateTime DateTime1
    {
        // Omitted for brevity
    }

    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.AddDays(-1);
entity.DateTime2 = DateTime.Today;

bool result = entity.IsValid();


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

bool result = entity.IsValid();

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

Comments

No comments yet.