Validate node
(node: &Node, ctx: &mut ValidationContext, errors: &mut Vec<ValidationError>)
| 2481 | |
| 2482 | /// Validate node |
| 2483 | fn validate_node(node: &Node, ctx: &mut ValidationContext, errors: &mut Vec<ValidationError>) { |
| 2484 | // Declare variable if node has an identifier |
| 2485 | if let Some(ref identifier) = node.identifier { |
| 2486 | ctx.declared_variables.insert(identifier.clone()); |
| 2487 | ctx.variable_types |
| 2488 | .insert(identifier.clone(), GqlType::String { max_length: None }); // Node as generic type |
| 2489 | } |
| 2490 | |
| 2491 | // Validate labels |
| 2492 | for label in &node.labels { |
| 2493 | if label.is_empty() { |
| 2494 | errors.push(ValidationError { |
| 2495 | message: "Node label cannot be empty".to_string(), |
| 2496 | location: Some(node.location.clone()), |
| 2497 | error_type: ValidationErrorType::Syntax, |
| 2498 | }); |
| 2499 | } |
| 2500 | } |
| 2501 | |
| 2502 | // Validate properties if present |
| 2503 | if let Some(properties) = &node.properties { |
| 2504 | for property in &properties.properties { |
| 2505 | validate_expression(&property.value, ctx, errors); |
| 2506 | } |
| 2507 | } |
| 2508 | } |
| 2509 | |
| 2510 | /// Validate edge |
| 2511 | fn validate_edge(edge: &Edge, ctx: &mut ValidationContext, errors: &mut Vec<ValidationError>) { |
no test coverage detected