computeStrength
PasswordField
stable
Pure function (no Vue reactivity needed) that scores a password string on a 0-4 scale based on length, digit presence, case diversity, and special characters. Returns a numeric score and a semantic level (weak / fair / good / strong). Used internally by OrigamPasswordField to drive the strength bar colour and label. No third-party dependencies.
API
Signature
Full TypeScript signature sourced from the composable file.
Consumed interfaces
IPasswordStrength
API
Parameters
Input parameters accepted by this composable.
- valuerequiredstring | null | undefined
- The password string to evaluate. Null and undefined are treated as empty (score 0, level "weak").
API
Return values
Properties and methods exposed by the composable return object.
- score
- Heuristic score in [0, 4]. Each criterion adds 1 point: length ≥ 8, length ≥ 12, contains digit, mixed case, non-alphanumeric character.
- level
- Human-readable level mapped from the score: 0-1 = weak, 2 = fair, 3 = good, 4 = strong.
Usage
Examples
Ready-to-paste usage snippets.
Reactive strength indicator
Via OrigamPasswordField prop