public static boolean isValidRule(GatewayFlowRule rule) {
        if (rule == null || StringUtil.isBlank(rule.getResource()) || rule.getResourceMode() < 0
                || rule.getGrade() < 0 || rule.getCount() < 0 || rule.getBurst() < 0 || rule.getControlBehavior() < 0) {
            return false;
        }
        if (rule.getControlBehavior() == RuleConstant.CONTROL_BEHAVIOR_RATE_LIMITER
                && rule.getMaxQueueingTimeoutMs() < 0) {
            return false;
        }
        if (rule.getIntervalSec() <= 0) {
            return false;
        }
        GatewayParamFlowItem item = rule.getParamItem();
        if (item != null) {
            return isValidParamItem(item);
        }
        return true;
    }
@Test
    public void testIsValidRule() {
        GatewayFlowRule bad1 = new GatewayFlowRule();
        GatewayFlowRule bad2 = new GatewayFlowRule("abc")
            .setIntervalSec(0);
        GatewayFlowRule bad3 = new GatewayFlowRule("abc")
            .setParamItem(new GatewayParamFlowItem()
                .setParseStrategy(SentinelGatewayConstants.PARAM_PARSE_STRATEGY_URL_PARAM));
        GatewayFlowRule bad4 = new GatewayFlowRule("abc")
            .setParamItem(new GatewayParamFlowItem()
                .setParseStrategy(SentinelGatewayConstants.PARAM_PARSE_STRATEGY_URL_PARAM)
                .setFieldName("p")
                .setPattern("def")
                .setMatchStrategy(-1)
            );
        GatewayFlowRule good1 = new GatewayFlowRule("abc");
        GatewayFlowRule good2 = new GatewayFlowRule("abc")
            .setParamItem(new GatewayParamFlowItem().setParseStrategy(0));
        GatewayFlowRule good3 = new GatewayFlowRule("abc")
            .setParamItem(new GatewayParamFlowItem()
                .setMatchStrategy(SentinelGatewayConstants.PARAM_PARSE_STRATEGY_HEADER)
                .setFieldName("Origin")
                .setPattern("def"));
        assertFalse(GatewayRuleManager.isValidRule(bad1));
        assertFalse(GatewayRuleManager.isValidRule(bad2));
        assertFalse(GatewayRuleManager.isValidRule(bad3));
        assertFalse(GatewayRuleManager.isValidRule(bad4));

        assertTrue(GatewayRuleManager.isValidRule(good1));
        assertTrue(GatewayRuleManager.isValidRule(good2));
        assertTrue(GatewayRuleManager.isValidRule(good3));
    }