Validate address start date to not be in the past - validation not firing
Summary:
We want to prevent employees from entering a new address with a past date.
Content (please ensure you mask any confidential information):
Below is what I have and it is not working.
/* eslint-disable dot-notation */
define([], () => { 'use strict';
/** @param {object} context * @return {boolean} */
function runCondition(context) {
const { $componentContext, $fields, $modules, $user } = context;
// Get current date and set to midnight
const currentDate = new Date();
currentDate.setHours(0, 0, 0, 0); // Get and convert the start date
const effectiveStartDateValue = $fields.personAddress.EffectiveStartDate.$value();
const parts = effectiveStartDateValue.split('-');
const effectiveStartDate = new Date(parseInt(parts[0]), parseInt(parts[1]) - 1, parseInt(parts[2]));
// Compare the dates and return the result directly