Skip to content

Commit

Permalink
fix(api): schema validation problem in mapping rule in dto (#1995)
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren authored Sep 25, 2024
1 parent da3398c commit b512179
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions keep/api/models/db/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class MappingRuleDtoOut(MappRuleDtoBase, extra="ignore"):
class MappingRuleDtoIn(MappRuleDtoBase):
rows: Optional[list[dict]] = None

@validator("type", pre=True, always=True)
def validate_type(cls, _type, values):
if _type == "csv" and not values.get("rows"):
@validator("rows", pre=True, always=True)
def validate_rows(cls, rows, values):
if not rows and values.get("type") == "csv":
raise ValueError("Mapping of type CSV cannot have empty rows")
return _type
return rows

0 comments on commit b512179

Please sign in to comment.