gitlab
gitlab copied to clipboard
Refactor options validation
@travi @JonasSchubert I'd suggest to tackle this in two steps:
- Merge this fix to unblock folks asap.
- Create a follow-up issue to refactor the option validation. IMO it's super brittle and we should clean it up properly so that we cannot run into these kinds of issue in the future. We should somehow encapsulate options, their validation and error messages better.
Originally posted by @fgreinacher in https://github.com/semantic-release/gitlab/pull/364#issuecomment-1098849915
How shall we continue here? To keep it similar to semantic-release/github I simply would add the missing validations and write a Unit Test checking whether all validations are covered (Including new validations). Or did you consider a bigger refactoring @fgreinacher ?
I had a slightly bigger change in mind, encapsulating configuration options, validation logic and error messages, conceptually something like this:
options: [
{
name: "assets",
validate: (value, errors) => {
if (!value) errors.push("Missing value for option assets...");
// ...
}
]
We could afterwards do the same refactoring for the GitHub plugin. WDYT @travi?