How to get specific property values from array of objects and compare them

Array
(
[REL0000020GBPTN1:PRO0000353GBPTN1] =>
[REL0000020GBPTN1:PRO0000306GBPTN1] => 2025-03-30 00:00:00
[REL0000020GBPTN1:PRO0000403GBPTN2] => 2025-03-03 00:00:00
[REL0000020GBPTN1:PRO0000309GBPTN1] =>
[REL0000020GBPTN1:PRO0000315GBPTN1] =>
[:id] => 3369
[REL0000020GBPTN1,REL0000061GBPTN1:id] => Array
(
)

)

i need to compare these two dates, validator is created on one of the property now how to compare with other date property. the above response is from get values method

Hi Uddhav,

Short answer is you will need to create References for each property we need to validate. Here is a code sample which will hopefully help.

//Check that start date is less than end date.
 
/* Start */
 
const debug=false;
cs.log ("Running Fragment Validator - Validating vs Another Form Value");
 
/*Get Field Value */
var input_val = fragment_presenter.get_value();
 
if(debug){cs.log("Input End Date - "+input_val)};
 
// Get form values
var frm_vals = fragment_presenter.get_values();
 
if(debug){cs.log(frm_vals)};
 
// Get Start date from Field Path Reference
var start = frm_vals[cs.ref('Start_Date')];
 
if(debug){cs.log("start - "+start)};
 
//entered dates
var startdate = (start);
var enddate = (input_val);
 
//If entered date is > start date, return false ELSE true
 
if(startdate > enddate) {
    return {valid:false, error:"End Date cannot be before Start Date"}
}
else {
    return {valid:true};
}