Skip to content
Snippets Groups Projects
Commit f0b6ad0f authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

better error msg

parent d37f2cdd
No related branches found
No related tags found
2 merge requests!122Front matter linter,!93Resolve "front-matter linter"
Pipeline #116629 passed
This commit is part of merge request !93. Comments created here will be created in the context of that merge request.
......@@ -2,7 +2,7 @@ import typer
from typing_extensions import Annotated
from typing import Optional, List
from pathlib import Path
from pydantic import BaseModel
from pydantic import BaseModel, ValidationError
from pydantic_yaml import parse_yaml_raw_as, to_yaml_str
import frontmatter
from enum import Enum
......@@ -54,6 +54,12 @@ def lint(
with open(file) as f:
metadata, _ = frontmatter.parse(f.read())
# print(metadata)
FrontMatter.model_validate(metadata)
# print(val)
try:
FrontMatter.model_validate(metadata)
except ValidationError as exc:
# print(repr(exc.errors()[0]["type"]))
# print(repr(exc))
# print(exc.errors())
for err in exc.errors():
print(f"{err['msg']} : {err['type']} {err['loc']}")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment