It isn't the responsibility of the data layer to handle the user input.
If we are talking about user input try to add uniqueness validation into front end form or on the backend handler.
The better to use both options. The front end checks uniqueness among editing pairs but the backend handler checks uniqueness among all existing pairs (it needs additional query to the database).
When validations are passed then you can safely send the data to the data layer for saving.