Skip to content

Commit

Permalink
add validation for title uniqueness
Browse files Browse the repository at this point in the history
  • Loading branch information
kamicut committed Jul 10, 2024
1 parent 424a07b commit 867049e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/crud/atbds.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ def create( # type: ignore
which needs to be saved as a field of the AtbdVersion, gets generated when
serializing the Atbd to the database."""

# Uniqueness validation for title
if (atbd_input.title is not None) and db.query(db.query(Atbds).filter(Atbds.title == atbd_input.title).exists()).scalar():
raise HTTPException(
status_code=400,
detail="The ATBD title is already in use. Please provide a different title.",
)

# Unique validation
if (
atbd_input.alias is not None
Expand Down

0 comments on commit 867049e

Please sign in to comment.