(env: Environment)
| 44 | |
| 45 | |
| 46 | def _validate_form(env: Environment) -> FormDoc: |
| 47 | ctx = get_current_context() |
| 48 | try: |
| 49 | return validate_doc(pathlib.Path.cwd() / ".beanhub" / "forms.yaml") |
| 50 | except (yaml.parser.ParserError, yaml.scanner.ScannerError) as exc: |
| 51 | env.logger.error("Invalid form document with YAML errors:") |
| 52 | rich.print(str(exc)) |
| 53 | ctx.exit(-1) |
| 54 | except ValidationError as exc: |
| 55 | env.logger.error("Invalid form document with errors:") |
| 56 | tree = errors_to_tree(exc.errors()) |
| 57 | rich.print(enrich_tree(tree)) |
| 58 | ctx.exit(-1) |
| 59 | except ValueError as exc: |
| 60 | env.logger.error(f"Failed to validate with error: {exc.args[0]}") |
| 61 | ctx.exit(-1) |
| 62 | |
| 63 | |
| 64 | @cli.command(help="Validate form schema file") |
no test coverage detected