RuleGo RuleGo
🏠Home
  • Quick Start
  • Rule Chain
  • Standard Components
  • Extension Components
  • Custom Components
  • Visualization
  • RuleGo-Server
  • RuleGo-MCP-Server
  • AOP
  • Trigger
  • Advanced Topics
  • Performance
  • Standard Components
  • Extension Components
  • Custom Components
  • Components Marketplace
  • Overview
  • Quick Start
  • Routing
  • DSL
  • API
  • Options
  • Components
🔥Editor (opens new window)
  • RuleGo Editor (opens new window)
  • RuleGo Server (opens new window)
  • Github (opens new window)
  • Gitee (opens new window)
  • Changelog (opens new window)
  • English
  • 简体中文
🏠Home
  • Quick Start
  • Rule Chain
  • Standard Components
  • Extension Components
  • Custom Components
  • Visualization
  • RuleGo-Server
  • RuleGo-MCP-Server
  • AOP
  • Trigger
  • Advanced Topics
  • Performance
  • Standard Components
  • Extension Components
  • Custom Components
  • Components Marketplace
  • Overview
  • Quick Start
  • Routing
  • DSL
  • API
  • Options
  • Components
🔥Editor (opens new window)
  • RuleGo Editor (opens new window)
  • RuleGo Server (opens new window)
  • Github (opens new window)
  • Gitee (opens new window)
  • Changelog (opens new window)
  • English
  • 简体中文

广告采用随机轮播方式显示 ❤️成为赞助商
  • Quick Start

  • Rule Chain

  • Standard Components

  • Extension Components

  • Custom Components

  • Components marketplace

  • Visualization

  • AOP

    • AOP Overview
    • Before Advice
    • After Advice
    • Around Advice
    • Start Advice
    • End Advice
    • Completed Advice
    • OnChainBeforeInit Advice
    • OnNodeBeforeInit 增强点
    • OnCreated Advice
    • OnReload Advice
    • OnDestroy Advice
    • builtin aspect

      • Debug Aspect
      • Fallback Aspect
      • Metrics Aspect
      • Concurrency Limiter Aspect
      • RuleChain Validator Aspect
        • Function Overview
          • Sub-Rule Chains Are Not Allowed to Create Endpoint Components
          • Cycle Detection
        • Custom Validation Rules
          • Creating Validation Functions
          • Registering Validation Rules
  • Trigger

  • Advanced Topic

  • RuleGo-Server

  • FAQ

  • Endpoint Module

  • Support

目录

RuleChain Validator Aspect

# Rule Chain Initialization Validator

The Rule Chain Initialization Validator is an important component used to verify whether the structure and configuration of a rule chain comply with relevant rules before the rule chain is started. Below is a detailed introduction to the Rule Chain Initialization Validator.

# Function Overview

# Sub-Rule Chains Are Not Allowed to Create Endpoint Components

  • Validation Rule: If a sub-rule chain (i.e., a rule chain with the Root attribute set to false) contains an Endpoint component, an error will be triggered.
  • Error Message: ErrNotAllowEndpointNode indicates that sub-rule chains are not allowed to create Endpoint components.

# Cycle Detection

  • Validation Rule: Nodes in the rule chain are not allowed to form cycles. If a cycle is detected, an error will be triggered. (The config.allowCycle switch controls whether cycles are allowed. The default is false, indicating that cycles are not allowed.)
  • Error Message: ErrCycleDetected indicates that a cycle reference has been detected in the rule chain.

# Custom Validation Rules

# Creating Validation Functions

Users can create custom validation functions by defining functions with the following signature:

func(config types.Config, def *types.RuleChain) error
1

Where:

  • config is the configuration information of the rule chain.
  • def is the definition of the rule chain.

# Registering Validation Rules

Use the Rules.AddRule() method to register custom validation functions with the rule validator. For example:

Rules.AddRule(func(config types.Config, def *types.RuleChain) error {
    if def != nil && len(def.Metadata.Nodes) > 10 {
        return errors.New("the rule chain cannot contain more than 10 nodes")
    }
    return nil
})
1
2
3
4
5
6
Edit this page on GitHub (opens new window)
Last Updated: 2025/03/31, 01:52:11
Concurrency Limiter Aspect
Trigger

← Concurrency Limiter Aspect Trigger→

Theme by Vdoing | Copyright © 2023-2025 RuleGo Team | Apache 2.0 License

  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式