I have books table and isbn field in it. When the user update existing book, if he changes the isbn code and save, isbn should be checked to unique, otherwise unique validation must be skipped.
There's unique validation but it is checking even isbn is not changed on update.
I have one idea. One variable will be added to Book model to keep old value of isbn. When the record is updated, old value and new value will be compared. If it is changed, custom validation will run.
Is it optimal way or is there any better way to do this?