Require unique by connected field to the logged-in user

Currently the platform allows a field to require unique values but this doesn't work when you have multiple users who enter rows into the same database, as they would be prevented from entering a code if another user used the same code.

It would be helpful if there were an option to require unique among the "logged-in user" or "database field connected to the logged-in user" in the case of multiple users in the same entity. This logic is used elsewhere for record rules.

Please advise if there is any way to do this with Javascript!