Validate simple CASE expressions
(
simple_case: &SimpleCaseExpression,
ctx: &mut ValidationContext,
errors: &mut Vec<ValidationError>,
)
| 1234 | |
| 1235 | /// Validate simple CASE expressions |
| 1236 | fn validate_simple_case_expression( |
| 1237 | simple_case: &SimpleCaseExpression, |
| 1238 | ctx: &mut ValidationContext, |
| 1239 | errors: &mut Vec<ValidationError>, |
| 1240 | ) { |
| 1241 | // Validate test expression |
| 1242 | validate_expression(&simple_case.test_expression, ctx, errors); |
| 1243 | |
| 1244 | // Validate WHEN branches |
| 1245 | for when_branch in &simple_case.when_branches { |
| 1246 | // Validate WHEN values |
| 1247 | for when_value in &when_branch.when_values { |
| 1248 | validate_expression(when_value, ctx, errors); |
| 1249 | } |
| 1250 | // Validate THEN expression |
| 1251 | validate_expression(&when_branch.then_expression, ctx, errors); |
| 1252 | } |
| 1253 | |
| 1254 | // Validate ELSE expression if present |
| 1255 | if let Some(else_expr) = &simple_case.else_expression { |
| 1256 | validate_expression(else_expr, ctx, errors); |
| 1257 | } |
| 1258 | |
| 1259 | // Check that there's at least one WHEN branch |
| 1260 | if simple_case.when_branches.is_empty() { |
| 1261 | errors.push(ValidationError { |
| 1262 | message: "CASE expression must have at least one WHEN branch".to_string(), |
| 1263 | location: Some(crate::ast::Location::default()), |
| 1264 | error_type: ValidationErrorType::Structural, |
| 1265 | }); |
| 1266 | } |
| 1267 | } |
| 1268 | |
| 1269 | /// Validate searched CASE expressions |
| 1270 | fn validate_searched_case_expression( |
no test coverage detected