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

import lombok.Getter;

/**
 * Immutable result returned by a {@link PasswordRule}.
 */
@Getter
public final class PasswordRuleResult {

    private final boolean valid;

    /** Human-readable failure reason; {@code null} when {@link #valid} is {@code true}. */
    private final String reason;

    private PasswordRuleResult(boolean valid, String reason) {
        this.valid  = valid;
        this.reason = reason;
    }

    /** Factory: rule passed. */
    public static PasswordRuleResult ok() {
        return new PasswordRuleResult(true, null);
    }

    /** Factory: rule failed with the supplied reason message. */
    public static PasswordRuleResult fail(String reason) {
        return new PasswordRuleResult(false, reason);
    }

}
