Repository navigation
feat: add the PasswordRequirement validator - #3
Merged
Merged
Conversation
- src/PasswordRequirement.php: laminas-validator 3 port of the axleus validator. Minimum length plus per-character-class counts, every failed rule reported rather than only the first, and a count of 0 imposes no requirement. - src/Container/PasswordRequirementFactory.php: merges the package defaults from config with the call-site options, call-site winning. - src/ConfigProvider.php: registers the validator and its factory under validators, with provisional 8/1/1/1/1 defaults. - tests: each rule alone, all rules together, exact and one-below boundaries, multibyte input, non-string input, string option values, message overrides, and the factory merge for both config sources. - composer.json / composer.lock: require laminas/laminas-validator ^3.18. Signed-off-by: Joey Smith <jsmith@webinertia.net>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Types of changes
Checklist:
Description
T1 of
webware-usermanager/docs/agent-plan-admin-create-user.md(plan section 16.2):Webware\Validator\PasswordRequirement.src/PasswordRequirement.php—final, extendsLaminas\Validator\AbstractValidator(v3). Minimum length (mb_strlen) plus upper / lower / digit / special counts (preg_match_all). Every failed rule is reported, not only the first. A count of0(or less) imposes no requirement, because no password can hold fewer than zero matches. The five counts are read through onecountOption()accessor and held asprotected readonly intproperties, which the$messageVariablesmap exposes as%length%/%upper%/%lower%/%digit%/%special%.src/Container/PasswordRequirementFactory.php— merges the defaults atconfig[$requestedName]with the call-site$options(call-site wins); with noconfigservice it uses$optionsalone.src/ConfigProvider.php— registers the validator undervalidators→factories, and declares the provisional defaultslength 8, upper 1, lower 1, digit 1, special 1.composer.json/composer.lock— requireslaminas/laminas-validator: ^3.18. Not in the task's file list; the class cannot load without it.Rebuild differences from the axleus original, per 16.2: no axleus dependency; typed
$messageTemplates/$messageVariables; own constructor storing the five counts; nosetValue()override (the parent's protected one is used), nogetOptions();mb_strlenoverstrlen; no adapter and noLaminas\Dbcoupling.Two deviations from the task text, both forced by the linter/analyzer and resolved at source (no suppression, no baseline):
failedRules()carries#[SensitiveParameter]on its$passwordparameter (magosensitive-parameteris an error).AbstractValidatorthrough a local annotated with the base class's option shape, because a plainarray<string, mixed>is too general for the parent's documented parameter type. The factory names its unused PSR-11 parameter$requestedNameand uses it as the config key.Motivation and Context
PasswordRequirementis the password validator the admin create-user work (and the later set-password step) builds on. It lives in this package so thatwebware-usermanagerdoes not have to own it.The five provisional defaults are the plan's
8 / 1 / 1 / 1 / 1; the plan marks them as the owner's to confirm.How has this been tested?
All gates on the WSL host with mago 1.51.0 (the version pinned by webware-tools
1.0.0-beta.8):mago fmt --checkmago lintmago analyzemago guardcomposer testcomposer test-integrationcomposer mutation-test -- --min-msi=95 --min-covered-msi=95Line coverage is 100% (69/69 lines, 7/7 methods, 3/3 classes) from
composer test-coverage.One mutant escapes, and it is equivalent:
countOption()'s?? 0→?? -1. A required count of-1and of0are indistinguishable, becausematches < 0is never true. Covered by the 95 floor with room to spare.Unit tests cover: each rule on its own; all rules together; a password meeting every rule; exact-count and one-below boundaries; multibyte input (
mb_strlen, not bytes); non-string andnullinput; string option values; message overrides reaching the base validator; and the factory merge for config-only, call-site-overrides-config, no-config-service and nothing-configured.Screenshots (if appropriate):
n/a