Skip to content

refactor: migrate services and middleware away from ValidateHelper - #8366

Merged
vitormattos merged 1 commit into
LibreSign:mainfrom
maia-andre:refactor/8355-validate-helper-services
Sep 12, 2026
Merged

refactor: migrate services and middleware away from ValidateHelper#8366
vitormattos merged 1 commit into
LibreSign:mainfrom
maia-andre:refactor/8355-validate-helper-services

Conversation

@maia-andre

Copy link
Copy Markdown
Contributor

Resolves: #8355

📝 Summary

Replaces the ValidateHelper compatibility façade with the focused validators in the four remaining central consumers, following the mapping defined in the issue:

consumer validators injected calls migrated
RequestSignatureService FileInputValidator, SigningRequestValidator, SignerValidator validateNewFile, validateFileStatus, validateIdentifySigners, normalizeRequestSigners (×3, same SignerValidator instance)
AccountService IdentityDocumentValidator, FileInputValidator userCanApproveValidationDocuments (×2), validateBase64 (×2), constant TYPE_VISIBLE_ELEMENT_USER now read from FileInputValidator
SignFileService IdentityDocumentValidator, SigningRequestValidator, SignerValidator userCanApproveValidationDocuments, fileCanBeSigned, validateUuidFormat, validateSigner, validateRenewSigner
InjectionMiddleware SigningRequestValidator, SignerValidator canRequestSign, validateSigner, validateSignerUuid

Dependency migration only:

  • no validation rule moves between validators;
  • no new façade, wrapper or interface;
  • SignFileService::validateSigner() and validateRenewSigner() keep their signatures and only change the delegate;
  • InjectionMiddleware attributes, authorization flow, exception handling and redirects are untouched;
  • the new constructor parameters take the position the ValidateHelper parameter had, so the positional constructor calls in the tests stay readable.

After this change the only ValidateHelper consumers left in lib/ are the three controllers covered by #8353, plus the façade itself. In tests/, only PageControllerTest (for PageController, also #8353) and ValidateHelperTest still reference it.

🧪 How to test

Ran in the devcontainer (PHP 8.3):

check result
php -l on the 8 files clean
php-cs-fixer --dry-run on the 8 files nothing to fix
psalm on the 4 production files, before vs. after same 8 pre-existing MissingDependency errors (local psr/* stubs), no new issue
RequestSignatureServiceTest + AccountServiceTest + SignFileServiceTest + InjectionMiddlewareTest OK, 214 tests, 554 assertions
ValidateHelperTest + PageControllerTest + Validation/* OK

Search to confirm the remaining references:

grep -rln ValidateHelper lib tests

⚙️ API / Back‑end changes

  • Constructor dependencies of the four classes changed from ValidateHelper to the focused validators (container-resolved; no public API change)
  • Unit tests updated: the ValidateHelper mock is replaced by one mock per focused validator, every existing expectation moved to the validator that owns the method, no assertion removed or weakened

🚧 Tasks

✅ Checklist

  • I have read and followed the contribution guide.
  • Commit signed off (DCO).
  • No new façade, wrapper or interface; no validation rule moved; no test removed or weakened.

🤖 AI (if applicable)

  • The content of this PR was partially or fully generated using AI

Replace the ValidateHelper compatibility façade with the focused
validators that already own each rule, in the four remaining central
consumers:

- RequestSignatureService: FileInputValidator::validateNewFile(),
  SigningRequestValidator::validateFileStatus(),
  SignerValidator::validateIdentifySigners() and
  normalizeRequestSigners()
- AccountService: IdentityDocumentValidator::
  userCanApproveValidationDocuments(), FileInputValidator::
  validateBase64() and FileInputValidator::TYPE_VISIBLE_ELEMENT_USER
- SignFileService: IdentityDocumentValidator::
  userCanApproveValidationDocuments(), SigningRequestValidator::
  fileCanBeSigned(), SignerValidator::validateUuidFormat(),
  validateSigner() and validateRenewSigner()
- InjectionMiddleware: SigningRequestValidator::canRequestSign(),
  SignerValidator::validateSigner() and validateSignerUuid()

Dependency migration only: no validation rule moves, no public
signature changes, no new wrapper. The unit tests replace the façade
mock with the focused validator mocks and keep every expectation.

Resolves: LibreSign#8355

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: André Maia <andrefnkmm@gmail.com>
@github-project-automation github-project-automation Bot moved this from 0. Backlog to 1. to do in Roadmap Sep 12, 2026
@vitormattos
vitormattos merged commit b8b2a08 into LibreSign:main Sep 12, 2026
67 checks passed
@github-project-automation github-project-automation Bot moved this from 1. to do to 4. to release in Roadmap Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 4. to release

Development

Successfully merging this pull request may close these issues.

Migrate remaining services and middleware away from ValidateHelper

2 participants