Simply put the unique attribute (UQ) in the field in the database, and it will no longer let you put an equal record. From the front you must make a query of the user that the document number resembles the one they send, it is a query more or less like this, "Select user from table where id like% iddelfront%"; then if that query returns something it is because there is a record, if it returns something will not save anything, that validation can be done in the saved controller that you have, that if you want an error message to appear to the user in the frontend, because just by putting the attribute in the field you would already have. I hope it serves you.