| 20 | namespace cel { |
| 21 | |
| 22 | Validation AstDepthValidator(int max_depth) { |
| 23 | return Validation([max_depth](ValidationContext& context) { |
| 24 | int height = context.navigable_ast().Root().height(); |
| 25 | if (height > max_depth) { |
| 26 | context.ReportError(absl::StrCat("AST depth ", height, |
| 27 | " exceeds maximum of ", max_depth)); |
| 28 | return false; |
| 29 | } |
| 30 | return true; |
| 31 | }); |
| 32 | } |
| 33 | |
| 34 | } // namespace cel |