package com.dji.sample.manage.model.password;

/**
 * Strategy interface for a single password validation rule.
 * <p>
 * Each implementation encapsulates one specific rule (length, character categories,
 * weak-password list, etc.) and returns a {@link PasswordRuleResult} indicating
 * whether the password passes the rule and, on failure, an explanatory message.
 * </p>
 * <p>
 * Implementations are registered as Spring components and collected by
 * {@link com.dji.sample.manage.service.password.PasswordRuleChain}.
 * </p>
 */
public interface PasswordRule {

    /**
     * Validate the given password against this rule.
     *
     * @param password plain-text password to validate (never {@code null})
     * @param context  optional user context; may be {@code null} for anonymous checks
     * @return {@link PasswordRuleResult#ok()} on success, or
     *         {@link PasswordRuleResult#fail(String)} with a human-readable reason
     */
    PasswordRuleResult validate(String password, PasswordRuleContext context);

    /**
     * Display name of this rule — used for logging and management UI.
     *
     * @return rule name
     */
    String getRuleName();

}
