Customer creation from Lead should restrict to duplication of customer name

Creating Customer from Lead, but system allowing me to create same customer name again, this should be restricted to avoide confusion.
In customizr form I tick ti unique checkbox then also customer get created with the same name.

Try to add Server script to check and validate before insert.

if frappe.db.exists("Customer", {"customer_name": data.customer_name}):
    frappe.throw(_("Customer with name '{0}' already exists").format(data.customer_name))

Thank you Hardik for your reply. I tried this script but there is an error that customer already exists even if customer name is new.

Hello Hardik, this server script is working for me.
Thank you so much for your support.