diff --git a/src/cdk/v2/destinations/zoho/utils.js b/src/cdk/v2/destinations/zoho/utils.js index 8b170d2b82..4f5c4e8620 100644 --- a/src/cdk/v2/destinations/zoho/utils.js +++ b/src/cdk/v2/destinations/zoho/utils.js @@ -3,6 +3,7 @@ const { getHashFromArray, isDefinedAndNotNull, ConfigurationError, + isDefinedAndNotNullAndNotEmpty, } = require('@rudderstack/integrations-lib'); const get = require('get-value'); const { getDestinationExternalIDInfoForRetl, isHttpStatusSuccess } = require('../../../../v0/util'); @@ -31,7 +32,10 @@ const deduceModuleInfo = (inputs, Config) => { function validatePresenceOfMandatoryProperties(objectName, object) { if (zohoConfig.MODULE_MANDATORY_FIELD_CONFIG.hasOwnProperty(objectName)) { const requiredFields = zohoConfig.MODULE_MANDATORY_FIELD_CONFIG[objectName]; - const missingFields = requiredFields.filter((field) => !object.hasOwnProperty(field)) || []; + const missingFields = + requiredFields.filter( + (field) => !object.hasOwnProperty(field) || !isDefinedAndNotNullAndNotEmpty(object[field]), + ) || []; return { status: missingFields.length > 0, missingField: missingFields }; } // No mandatory check performed for custom objects diff --git a/src/cdk/v2/destinations/zoho/utils.test.js b/src/cdk/v2/destinations/zoho/utils.test.js index 332a408695..5a11794ef5 100644 --- a/src/cdk/v2/destinations/zoho/utils.test.js +++ b/src/cdk/v2/destinations/zoho/utils.test.js @@ -130,6 +130,24 @@ describe('validatePresenceOfMandatoryProperties', () => { expect(() => validatePresenceOfMandatoryProperties(objectName, object)).not.toThrow(); }); + it('should return missing field if mandatory field contains empty string', () => { + const objectName = 'Leads'; + const object = { Last_Name: '' }; + + const result = validatePresenceOfMandatoryProperties(objectName, object); + + expect(result).toEqual({ missingField: ['Last_Name'], status: true }); + }); + + it('should return missing field if mandatory field contains empty null', () => { + const objectName = 'Leads'; + const object = { Last_Name: null }; + + const result = validatePresenceOfMandatoryProperties(objectName, object); + + expect(result).toEqual({ missingField: ['Last_Name'], status: true }); + }); + it('should not throw an error if the objectName is not in MODULE_MANDATORY_FIELD_CONFIG', () => { const objectName = 'CustomObject'; const object = { Some_Field: 'Some Value' };