| 40 | ) |
| 41 | |
| 42 | def validate(self, config: dict[str, Any]) -> list[str]: |
| 43 | errors = super().validate(config) |
| 44 | if "condition" not in config: |
| 45 | errors.append( |
| 46 | f"Do-while step {config.get('id', '?')!r} is missing " |
| 47 | f"'condition' field." |
| 48 | ) |
| 49 | max_iter = config.get("max_iterations") |
| 50 | if max_iter is not None: |
| 51 | # bool is a subclass of int, so isinstance(True, int) is True and |
| 52 | # True < 1 is False; reject bools explicitly so `max_iterations: true` |
| 53 | # is a type error rather than a silent single iteration. |
| 54 | if isinstance(max_iter, bool) or not isinstance(max_iter, int) or max_iter < 1: |
| 55 | errors.append( |
| 56 | f"Do-while step {config.get('id', '?')!r}: " |
| 57 | f"'max_iterations' must be an integer >= 1." |
| 58 | ) |
| 59 | nested = config.get("steps", []) |
| 60 | if not isinstance(nested, list): |
| 61 | errors.append( |
| 62 | f"Do-while step {config.get('id', '?')!r}: 'steps' must be a list." |
| 63 | ) |
| 64 | return errors |