ValidateHelper was split into focused validators in #8334. Several consumers have already been migrated in follow-up PRs, including #8336, #8337, #8343, #8345 and #8355.
This issue covers the remaining controller consumers of ValidateHelper.
The goal is to replace calls through the compatibility façade with direct calls to the focused validators that already own each validation rule.
Do not change validation behavior.
What needs to change
Update these consumers:
FileController
Replace the ValidateHelper dependency with:
FileInputValidator
SigningRequestValidator
Use them as follows:
ValidateHelper::validateNewFile() → FileInputValidator::validateNewFile()
ValidateHelper::canRequestSign() → SigningRequestValidator::canRequestSign()
ValidateHelper::iRequestedSignThisFile() → SigningRequestValidator::iRequestedSignThisFile()
Migrate all current calls in FileController. After this change, FileController must no longer import, inject or call ValidateHelper.
PageController
Replace the ValidateHelper dependency with SigningRequestValidator.
Use:
ValidateHelper::canRequestSign() → SigningRequestValidator::canRequestSign()
After this change, PageController must no longer import, inject or call ValidateHelper.
AccountController
ValidateHelper is injected but is not used.
Remove the ValidateHelper constructor dependency and import.
Do not replace it with another validator.
Focused validators
The validation rules are currently split into:
FileInputValidator: file input, MIME type and LibreSign file ID validation.
VisibleElementValidator: visible signature element validation.
SigningRequestValidator: signing-request state, permissions and file-signing workflow validation.
SignerValidator: signer identity, UUID and credential validation.
IdentityDocumentValidator: identification-document validation and approval rules.
Do not introduce another façade, wrapper or validation interface.
Each controller should inject only the focused validators required by its current validation calls.
Tests
Update every affected unit test that creates one of these controllers directly.
For the affected tests:
- replace
ValidateHelper mocks with FileInputValidator and/or SigningRequestValidator mocks as required;
- remove obsolete
ValidateHelper mocks where the dependency is removed;
- update constructor arguments;
- move existing method expectations to the corresponding focused validator mock;
- keep the existing assertions and behavior coverage;
- do not remove or weaken tests to make the migration pass.
The change must not modify validation behavior or any public API.
Scope
This issue is limited to:
FileController
PageController
AccountController
- their affected tests
The service and middleware consumers were handled separately in #8355.
Do not remove ValidateHelper itself in this issue. Its final removal is tracked by #8357 and should happen only after this migration is complete.
Do not:
- change validation rules;
- move validation logic between focused validators;
- rename validator methods or constants;
- change controller public APIs;
- change exception or HTTP response behavior;
- introduce another validation façade or wrapper;
- include unrelated cleanup or refactoring.
Before submitting the PR
Search the three affected production controllers for:
There should be no remaining imports, constructor dependencies or calls.
Also search their affected tests and make sure no obsolete ValidateHelper mocks remain.
A repository-wide search may still find the compatibility façade itself and its dedicated test. Those are handled by #8357.
Done when
Good first issue
You do not need to understand the complete LibreSign codebase to work on this issue.
The validation architecture has already been split into focused validators. This task only migrates the remaining controller consumers away from the compatibility façade.
A good way to start is:
- Read one affected controller and its unit tests.
- Find every
ValidateHelper call in that controller.
- Replace each call with the focused validator that already owns that method.
- Update the related mocks and constructor arguments.
- Run the related PHPUnit tests.
- Repeat for the other controllers.
- Search the affected files for
ValidateHelper before submitting the PR.
This is a good way to learn dependency injection, PHPUnit mocks and the LibreSign validation architecture while working on a focused change.
If anything in the expected change is unclear, feel free to ask in this issue before starting.
Additional context
- If you have questions, feel free to ask in this issue.
- Give a ⭐️ star to this repository if you find LibreSign useful and would like to support the project.
- You can also join our community: https://t.me/LibreSign
ValidateHelperwas split into focused validators in #8334. Several consumers have already been migrated in follow-up PRs, including #8336, #8337, #8343, #8345 and #8355.This issue covers the remaining controller consumers of
ValidateHelper.The goal is to replace calls through the compatibility façade with direct calls to the focused validators that already own each validation rule.
Do not change validation behavior.
What needs to change
Update these consumers:
FileControllerReplace the
ValidateHelperdependency with:FileInputValidatorSigningRequestValidatorUse them as follows:
ValidateHelper::validateNewFile()→FileInputValidator::validateNewFile()ValidateHelper::canRequestSign()→SigningRequestValidator::canRequestSign()ValidateHelper::iRequestedSignThisFile()→SigningRequestValidator::iRequestedSignThisFile()Migrate all current calls in
FileController. After this change,FileControllermust no longer import, inject or callValidateHelper.PageControllerReplace the
ValidateHelperdependency withSigningRequestValidator.Use:
ValidateHelper::canRequestSign()→SigningRequestValidator::canRequestSign()After this change,
PageControllermust no longer import, inject or callValidateHelper.AccountControllerValidateHelperis injected but is not used.Remove the
ValidateHelperconstructor dependency and import.Do not replace it with another validator.
Focused validators
The validation rules are currently split into:
FileInputValidator: file input, MIME type and LibreSign file ID validation.VisibleElementValidator: visible signature element validation.SigningRequestValidator: signing-request state, permissions and file-signing workflow validation.SignerValidator: signer identity, UUID and credential validation.IdentityDocumentValidator: identification-document validation and approval rules.Do not introduce another façade, wrapper or validation interface.
Each controller should inject only the focused validators required by its current validation calls.
Tests
Update every affected unit test that creates one of these controllers directly.
For the affected tests:
ValidateHelpermocks withFileInputValidatorand/orSigningRequestValidatormocks as required;ValidateHelpermocks where the dependency is removed;The change must not modify validation behavior or any public API.
Scope
This issue is limited to:
FileControllerPageControllerAccountControllerThe service and middleware consumers were handled separately in #8355.
Do not remove
ValidateHelperitself in this issue. Its final removal is tracked by #8357 and should happen only after this migration is complete.Do not:
Before submitting the PR
Search the three affected production controllers for:
There should be no remaining imports, constructor dependencies or calls.
Also search their affected tests and make sure no obsolete
ValidateHelpermocks remain.A repository-wide search may still find the compatibility façade itself and its dedicated test. Those are handled by #8357.
Done when
FileControllerusesFileInputValidatorandSigningRequestValidatordirectly.FileControllerno longer imports, injects or callsValidateHelper.PageControllerusesSigningRequestValidatordirectly.PageControllerno longer imports, injects or callsValidateHelper.AccountControllerno longer imports or injectsValidateHelper.Good first issue
You do not need to understand the complete LibreSign codebase to work on this issue.
The validation architecture has already been split into focused validators. This task only migrates the remaining controller consumers away from the compatibility façade.
A good way to start is:
ValidateHelpercall in that controller.ValidateHelperbefore submitting the PR.This is a good way to learn dependency injection, PHPUnit mocks and the LibreSign validation architecture while working on a focused change.
If anything in the expected change is unclear, feel free to ask in this issue before starting.
Additional context