package com.ruoyi.common.core.domain;

/**
 * @author qzz
 * 2024/4/16
 */
public class BaseValidator {

    public static ValidateResult success() {
        return ValidateResult.success();
    }

    public static ValidateResult error(String msg) {
        return ValidateResult.error(msg);
    }

    public static ValidateResult error(int code, String msg) {
        return ValidateResult.error(code, msg);
    }

    /**
     * 当有一个失败，则返回失败
     * @param results
     * @return
     */
    public ValidateResult hasOneError(ValidateResult ...results) {
        for (ValidateResult result : results) {
            if (result.isError()) {
                return result;
            }
        }
        return success();
    }
}
