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
Signature TypeScript complète extraite du fichier du composable.
Interfaces consommées
IPasswordStrength
API
Paramètres
Paramètres d'entrée acceptés par ce composable.
- valuerequisstring | null | undefined
- The password string to evaluate. Null and undefined are treated as empty (score 0, level "weak").
API
Valeurs de retour
Propriétés et méthodes exposées par l'objet retourné par le composable.
- 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
Exemples
Extraits de code prêts à coller.
Reactive strength indicator
Via OrigamPasswordField prop