We have an integration with an external client that pushes data into our system through a REST API.
For validation issues related to the payload (data transfer objects), we return 422 Unprocessable Entity if something is not accurate.
Now, when we have scenarios like adding a new user and the user exists on the database, we consider this as a validation error as well, and we don't allow the client to submit the user information because it was already persisted.
Is the 422 status code valid for this type of scenario where we want to avoid duplicate records?