I’m trying to validate an object that has beginDate
and endDate
properties. As part of the validation, I need to ensure that beginDate
is “before” endDate
. I tried doing the following:
ValidationRules
.ensure((s:Session) => s.beginDate)
.required()
.satisfies((s:Session) => moment(s.beginDate).isBefore(s.endDate))
.on(Session);
Of course, this doesn’t work because the beginDate
– not the Session
object – is what is actually being passed to the satisfies()
function.
How can I get access to both beginDate
and endDate
in the satisfies()
validation rule?