Skip to content

DRY: Validation logic triplicated across Servy, Manager, and CLI (~600 lines) #404

@Christophe-Rogiers

Description

@Christophe-Rogiers

Description

Three separate validators contain nearly identical validation logic (~200 lines each):

  • src/Servy/Validators/ServiceConfigurationValidator.cs (~226 lines)
  • src/Servy.Manager/Validators/ServiceConfigurationValidator.cs (~216 lines)
  • src/Servy.CLI/Validators/ServiceInstallValidator.cs (~176 lines)

All three check the same fields in the same order: Name, ExecutablePath, paths, timeouts, rotation, health monitoring, failure program, env vars, dependencies, credentials, pre/post-launch/stop hooks. Only the error reporting mechanism differs (MessageBox vs CommandResult).

Estimated redundant lines: ~600

Suggested fix

Extract a shared ServiceValidationRules class in Servy.Core that returns a list of validation errors. Each project's validator becomes a thin wrapper feeding errors to its own UI mechanism.

Metadata

Metadata

Assignees

Labels

refactorChanges that improve structure, readability, or maintainability without altering external behavior

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions