| 349 | return False |
| 350 | |
| 351 | async def validate(self) -> list[HookValidationError]: |
| 352 | if not self._settings_path.exists(): |
| 353 | return [] |
| 354 | |
| 355 | try: |
| 356 | data = json.loads(self._settings_path.read_text(encoding="utf-8")) |
| 357 | except (json.JSONDecodeError, OSError): |
| 358 | return [HookValidationError( |
| 359 | event="", |
| 360 | index=-1, |
| 361 | field="file", |
| 362 | message=f"Cannot read settings file: {self._settings_path}", |
| 363 | )] |
| 364 | |
| 365 | hooks_raw = data.get("hooks", {}) |
| 366 | if not isinstance(hooks_raw, dict): |
| 367 | return [HookValidationError( |
| 368 | event="", |
| 369 | index=-1, |
| 370 | field="hooks", |
| 371 | message="'hooks' field must be an object", |
| 372 | )] |
| 373 | |
| 374 | return validate_hook_configs(hooks_raw) |