Pretty easy to do with NH Validator. There is one catch if you lazy load during validation (because of the late event it is running in), it will lead to the DefaultFlushEventListener throwing an exception. It isn't necessary for it to do so & it will not block persistence if you ignore it using the event listener code below.
public class YourObjectValidationDef : ValidationDef<YourObject> {
public YourObjectValidationDef() {
this.ValidateInstance.By((obj, context) => {
context.DisableDefaultError();
bool valid = (obj.Index == 0 || obj.StartDate >= obj.Parent.Children[obj.Index - 1].EndDate);
if (!valid)
context.AddInvalid("Add your error message here", "StartDate");
return flag;
});
}
public class FlushFixEventListener : DefaultFlushEventListener {
public override void OnFlush(FlushEvent @event) {
try {
base.OnFlush(@event);
}
catch (AssertionFailure) {
// throw away
}
}
}