Skip to content

Commit

Permalink
#2034 - Update student form to validate new separate minimum offering…
Browse files Browse the repository at this point in the history
… days for Fulltime vs Parttime. (#2091)

#2034 - Update student form to validate new separate minimum offering days for Fulltime vs Parttime. (#2091)
  • Loading branch information
ann-aot authored Jul 10, 2023
1 parent 7b4d86c commit c62860b
Show file tree
Hide file tree
Showing 3 changed files with 32,747 additions and 32,633 deletions.
42 changes: 40 additions & 2 deletions sources/packages/forms/src/form-definitions/sfaa2021-22.json
Original file line number Diff line number Diff line change
Expand Up @@ -2652,7 +2652,7 @@
"tableView": true,
"validate": {
"required": true,
"custom": "// To calculate the time difference of two dates\r\nconst Difference_In_Time = new Date(data.studyendDate).getTime() - new Date(data.studystartDate).getTime();\r\n \r\n// To calculate the no. of days between two dates\r\nconst Difference_In_Days = Difference_In_Time / (1000 * 3600 * 24);\r\nvalid = (data.studystartDate) ? \r\n ((Difference_In_Days >= 42) && (Difference_In_Days <= 365)) ? \r\n true : \"Invalid Study Period, Dates must be between 42 and 365 days\" : \r\n\"Please provide Study Start date\";",
"custom": "// To calculate the time difference of two dates\r\nconst Difference_In_Time =\r\n new Date(data.studyendDate).getTime() -\r\n new Date(data.studystartDate).getTime();\r\n\r\n// To calculate the no. of days between two dates\r\nconst Difference_In_Days = Difference_In_Time / (1000 * 3600 * 24);\r\nvalid = data.studystartDate\r\n ? Difference_In_Days >= data.studyPeriodMinDays &&\r\n Difference_In_Days <= data.studyPeriodMaxDays\r\n ? true\r\n : `Invalid Study Period, Dates must be between ${data.studyPeriodMinDays} and ${data.studyPeriodMaxDays} days`\r\n : \"Please provide Study Start date\";",
"customPrivate": false,
"strictDateValidation": false,
"multiple": false,
Expand Down Expand Up @@ -2694,7 +2694,7 @@
"attributes": {},
"validateOn": "change",
"conditional": {
"show": null,
"show": "",
"when": null,
"eq": ""
},
Expand Down Expand Up @@ -5491,6 +5491,44 @@
"calculateServer": true,
"calculateValue": "/**\r\n * Validates if the date provided is before today.\r\n *\r\n * The same validation exists on calculating studyEndDateBeforeToday,\r\n * other student application forms, program information request form\r\n * and also on the server side.\r\n *\r\n * When there is an update to this logic make sure to update in all the above.\r\n *\r\n */\r\n\r\nfunction isGivenDateBeforeToday(givenDate) {\r\n return moment\r\n .utc(givenDate)\r\n .isBefore(moment.utc(new Date()).format(\"YYYY-MM-DD\"), \"day\");\r\n}\r\n\r\n// If a study period is selected, validate its study end date to be after given days before now.\r\nvalue =\r\n !!data.selectedOfferingEndDate &&\r\n isGivenDateBeforeToday(data.selectedOfferingEndDate);\r\n",
"isNew": false
},
{
"input": true,
"tableView": true,
"key": "studyPeriodMinDays",
"label": "Study period minimum days",
"protected": false,
"unique": false,
"persistent": true,
"type": "hidden",
"tags": [],
"conditional": {
"show": "",
"when": null,
"eq": ""
},
"properties": {},
"lockKey": true,
"calculateValue": "value = data.howWillYouBeAttendingTheProgram === \"Full Time\" ? 84 : 42;"
},
{
"input": true,
"tableView": true,
"key": "studyPeriodMaxDays",
"label": "Study period maximum days",
"protected": false,
"unique": false,
"persistent": true,
"type": "hidden",
"tags": [],
"conditional": {
"show": "",
"when": null,
"eq": ""
},
"properties": {},
"lockKey": true,
"defaultValue": "365"
}
],
"input": false,
Expand Down
Loading

0 comments on commit c62860b

Please sign in to comment.