mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 07:26:26 +00:00
refactor: customManager mandatory fields check (#28832)
This commit is contained in:
parent
5f1286ff00
commit
c3b9ef81e6
1 changed files with 14 additions and 7 deletions
|
@ -806,6 +806,19 @@ export async function validateConfig(
|
||||||
return { errors, warnings };
|
return { errors, warnings };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasField(
|
||||||
|
customManager: Partial<RegexManagerConfig>,
|
||||||
|
field: string,
|
||||||
|
): boolean {
|
||||||
|
const templateField = `${field}Template` as keyof RegexManagerTemplates;
|
||||||
|
return !!(
|
||||||
|
customManager[templateField] ??
|
||||||
|
customManager.matchStrings?.some((matchString) =>
|
||||||
|
matchString.includes(`(?<${field}>`),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function validateRegexManagerFields(
|
function validateRegexManagerFields(
|
||||||
customManager: Partial<RegexManagerConfig>,
|
customManager: Partial<RegexManagerConfig>,
|
||||||
currentPath: string,
|
currentPath: string,
|
||||||
|
@ -835,13 +848,7 @@ function validateRegexManagerFields(
|
||||||
|
|
||||||
const mandatoryFields = ['depName', 'currentValue', 'datasource'];
|
const mandatoryFields = ['depName', 'currentValue', 'datasource'];
|
||||||
for (const field of mandatoryFields) {
|
for (const field of mandatoryFields) {
|
||||||
const templateField = `${field}Template` as keyof RegexManagerTemplates;
|
if (!hasField(customManager, field)) {
|
||||||
if (
|
|
||||||
!customManager[templateField] &&
|
|
||||||
!customManager.matchStrings?.some((matchString) =>
|
|
||||||
matchString.includes(`(?<${field}>`),
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
errors.push({
|
errors.push({
|
||||||
topic: 'Configuration Error',
|
topic: 'Configuration Error',
|
||||||
message: `Regex Managers must contain ${field}Template configuration or regex group named ${field}`,
|
message: `Regex Managers must contain ${field}Template configuration or regex group named ${field}`,
|
||||||
|
|
Loading…
Reference in a new issue