func BuildRulesNode(ctx context.Context, n *node.Node, cache map[*node.Node][]system.RuleInterface) error { if n.Value == nil || n.Null || n.Missing { return nil } // Start with the rules from the type rules := n.Type.Rules if system.RulesApplyToObjects(n.Value) { ob := n.Value.(system.ObjectInterface).GetObject(nil) rules = append(rules, ob.Rules...) } if err := buildRulesObject(ctx, n, cache, rules); err != nil { return kerr.Wrap("KCXXUSBBEH", err) } return nil }
func buildRulesObjectChildren(ctx context.Context, n *node.Node, cache map[*node.Node][]system.RuleInterface) error { rules := []system.RuleInterface{} if system.RulesApplyToObjects(n.Value) { ob := n.Value.(system.ObjectInterface).GetObject(nil) rules = ob.Rules } for name, fieldRule := range n.UnderlyingInnerType.Fields { child := n.Map[name] fieldRules := rules fieldOb := fieldRule.(system.ObjectInterface).GetObject(nil) fieldRules = append(fieldRules, fieldOb.Rules...) if err := buildRulesObject(ctx, child, cache, fieldRules); err != nil { return kerr.Wrap("QXUGWLDDGN", err) } } return nil }