gitlab icon indicating copy to clipboard operation
gitlab copied to clipboard

Refactor options validation

Open fgreinacher opened this issue 2 years ago • 2 comments

@travi @JonasSchubert I'd suggest to tackle this in two steps:

  1. Merge this fix to unblock folks asap.
  2. 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

fgreinacher avatar Apr 18 '22 15:04 fgreinacher

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 ?

JonasSchubert avatar Apr 28 '22 17:04 JonasSchubert

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?

fgreinacher avatar Apr 28 '22 18:04 fgreinacher