Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: customManager mandatory fields check #28832

Merged
merged 4 commits into from
May 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions lib/config/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -833,15 +833,22 @@
});
}

const mandatoryFields = ['depName', 'currentValue', 'datasource'];
for (const field of mandatoryFields) {
function hasField(
rarkins marked this conversation as resolved.
Show resolved Hide resolved
customManager: Partial<RegexManagerConfig>,
field: string,
): boolean {
const templateField = `${field}Template` as keyof RegexManagerTemplates;
if (
!customManager[templateField] &&
!customManager.matchStrings?.some((matchString) =>
return !!(
customManager[templateField] ||

Check failure on line 842 in lib/config/validation.ts

View workflow job for this annotation

GitHub Actions / lint-eslint

Prefer using nullish coalescing operator (`??`) instead of a logical or (`||`), as it is a safer operator.
customManager.matchStrings?.some((matchString) =>
matchString.includes(`(?<${field}>`),
)
) {
);
}

const mandatoryFields = ['depName', 'currentValue', 'datasource'];
for (const field of mandatoryFields) {
if (!hasField(customManager, field)) {
errors.push({
topic: 'Configuration Error',
message: `Regex Managers must contain ${field}Template configuration or regex group named ${field}`,
Expand Down
Loading