How do I import error type in unique_constraint?

Hello,
please see my changeset code :

    def changeset(struct, params \\ %{}) do
        struct
        |> cast(params, [:full_name, :email, :password, :last_ip, :group_acl, :language, :country])
        |> validate_required([:full_name, :email, :password, :last_ip, :group_acl,:language, :country])
        |> validate_format(:email, ~r/@/)
        |> unique_constraint(:email, name: :index_of_users_unique_email, message: "email already exists.")
    end

you have an HTTP/1.1 400 Bad Request error in json webservice if you send bad request like not send any parameter to webservice.

So far everything is fine, but if you send duplicate email to webservice , you will have an 200 error in json webservice, but you should have an 400 error.

I think the error is for the sake of below code.

 |> unique_constraint(:email, name: :index_of_users_unique_email, message: "email already exists.")

#Ecto.Changeset<action: :insert,
 changes: %{country: "country", email: "sh@gl.com", full_name: "full_name",
   group_acl: "shahryar", language: "ex", last_ip: "last_ip",
   password: "$2b$12$uznPWTAL1uRHNexqtwR.YutDRM13Cxo4ayhOscWp8Dpnz77E1dZky"},
 errors: [email: {["email already exists."], []}],

##this error has an empty [ ]

but the normal error is :

#Ecto.Changeset<action: :insert,
 changes: %{email: "sh@gl.com", full_name: "full_name", group_acl: "shahryar",
   language: "ex", last_ip: "last_ip",
   password: "$2b$12$d0JZoQ6COeMbWmuZxET03eOTW41uDDthmnkdR6eqOvd8WMbH8gunK"},
 errors: [country: {"is invalid", [type: :string, validation: :cast]}],
 data: #TrangellUsersService.Login.Db.UsersInfo<>, valid?: false>

##this error has an full [type: :string, validation: :cast]

what is the difference in error between normal error and duplicate email ?

I think in [type: :string, validation: :cast]} , how do I import error type in unique_constraint ?