octobercms/october · error · ValidationException

Password must contain at least one nonalphanumeric…

Error message

Password must contain at least one nonalphanumeric character.

What it means

Validation failure in User::validatePasswordPolicy when require_nonalphanumeric is enabled and the password contains no symbol characters (the ctype-alnum filter over all characters fails). Special-character-presence guard over the policy config.

Solutions

  1. Include at least one non-alphanumeric character (symbol) in the password
  2. Disable require_nonalphanumeric in backend.password_policy if the policy is unwanted
  3. Show live policy hints in the password form to prevent submission failures
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at modules/backend/models/User.php:381 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21). Data as JSON: /api/errors/11ac48b9f6d01ece. Report an issue: GitHub.

Appendix: source

Thrown at modules/backend/models/User.php:381

                throw new ValidationException(['password' => __('Password must contain at least one uppercase character.')]);
            }
        }

        if ($policy['require_lowercase'] ?? false) {
            if (mb_strtoupper($password) === $password) {
                throw new ValidationException(['password' => __('Password must contain at least one lowercase character.')]);
            }
        }

        if ($policy['require_number'] ?? false) {
            if (!array_filter(str_split($password), 'is_numeric')) {
                throw new ValidationException(['password' => __('Password must contain at least one number.')]);
            }
        }

        if ($policy['require_nonalpha'] ?? false) {
            if (!Str::contains($password, str_split("!@#$%^&*()_+-=[]{}|'"))) {
                throw new ValidationException(['password' => __('Password must contain at least one nonalphanumeric character.')]);
            }
        }

        /**
         * @event user.validatePasswordPolicy
         * Called when the user password is validated against the policy
         *
         * Example usage:
         *
         *     $model->bindEvent('user.validatePasswordPolicy', function (string $password) use ($model) {
         *         throw new ValidationException(['password' => 'Prevent anything from validating ever!']);
         *     });
         *
         */
        $this->fireEvent('user.validatePasswordPolicy', compact('password'));
    }
}

View on GitHub (pinned to b608633a7e)