validateRules method

Future<bool> validateRules(
  1. Map<String, dynamic> nodes
)

Validates if the given rule nodes are well-formed

Implementation

Future<bool> validateRules(Map<String, dynamic> nodes) async {
  try {
    final ruleNodes = _convertNodesToRuleNodes(nodes);
    final supportedTypes = await getSupportedNodeTypes();

    // Validate each node
    for (final node in ruleNodes.values) {
      // Check required fields
      if (node.type.isEmpty || node.id.isEmpty) {
        return false;
      }
      // Check if type is supported
      if (!supportedTypes.contains(node.type)) {
        return false;
      }
    }
    return true;
  } catch (e) {
    return false;
  }
}