Alerting: Fix contact points secrets validation (#95651)

Add new condition to the determineRequired function
This commit is contained in:
Konrad Lalik 2024-11-04 13:15:48 +01:00 committed by GitHub
parent 0802ebcd1a
commit e43bec2cd8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -294,14 +294,17 @@ const validateOption = (value: string, validationRule: string, required: boolean
};
const determineRequired = (option: NotificationChannelOption, getValues: any, pathIndex: string) => {
const secureFields = getValues(`${pathIndex}secureFields`);
const secureSettings = getValues(`${pathIndex}secureSettings`);
if (!option.dependsOn) {
return option.required ? 'Required' : false;
}
if (isEmpty(getValues(`${pathIndex}secureFields`))) {
const dependentOn = getValues(`${pathIndex}secureSettings.${option.dependsOn}`);
return !Boolean(dependentOn) && option.required ? 'Required' : false;
if (isEmpty(secureFields) || !secureFields[option.dependsOn]) {
const dependentOn = Boolean(secureSettings[option.dependsOn]);
return !dependentOn && option.required ? 'Required' : false;
} else {
const dependentOn: boolean = getValues(`${pathIndex}secureFields.${option.dependsOn}`);
const dependentOn = Boolean(secureFields[option.dependsOn]);
return !dependentOn && option.required ? 'Required' : false;
}
};