adobe / adobe/aem-core-forms-components

Custom Function is not getting registered.

Open
#1,877 2 comments 0 reactions 1 assignee Claimed by @girotraapankaj View on GitHub
Dominant language
JavaScript
Stars
36
Forks
62
Avg merge
1d 6h
Merged PRs (30d)
8

Description

### Expected Behaviour
we created a custom function, that is being shown during authoring, but during runtime its not able to find it.

### Actual Behaviour
Function to execute

### Reproduce Scenario (including but not limited to)

#### Steps to Reproduce
/**
* @name validateDateOfBirth
* @param {object} field
* @param {number} upperAgeLimit - Enter the upper age limit value
* @returns {boolean} - True if valid, false otherwise
*/
function validateDateOfBirth(field, upperAgeLimit) {
const inputVal = field.$value;
if (!inputVal || (inputVal && Date.parse(inputVal) && new Date().setHours(0, 0, 0, 0) >= Date.parse(inputVal))) {
const today = new Date();
const inputDate = new Date(inputVal);

const inputDateArray = inputVal.split('/');
inputDate.setFullYear(parseInt(inputDateArray[inputDateArray.length - 1], 10));

const currentYear = today.getFullYear();
const inputYear = inputDate.getFullYear();

let leapYearCount = 0;
for (let i = inputYear; i <= currentYear; i++) {
if ((i % 4 === 0 && i % 100 !== 0) || i % 400 === 0) {
leapYearCount++;
}
}
const ageInDays = Math.floor(Math.floor(Math.floor(Math.floor((+today - +inputDate) / 1000) / 60) / 60) / 24);
const ageInYears = ((ageInDays - (366 * leapYearCount)) / 365) + leapYearCount;
return ageLimitCheck(ageInYears, upperAgeLimit);
} else {
return false;
}
}
/**
* @private
*/
function ageLimitCheck(ageInYears, upperAgeLimit) {
if (ageInYears >= 18) {
if (upperAgeLimit) {
return ageInYears < upperAgeLimit + 1 ? true : false;
} else {
return true;
}
} else {
return false;
}
}

Image

#### Platform and Version

#### AEM Version (mention the exact version in case of cloud SDK)
AEM 6.5.1 LTS

#### AEM Forms Version
1.1.74

#### Sample Code that illustrates the problem

#### Logs taken while reproducing problem
Image

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.