Skip to content

Unique tag seems doent work #1370

@MeNavel

Description

@MeNavel

i create request and using validator like this :

type CreateKtpRequest struct {
NIK string json:"nik" validate:"numeric,min=16,max=16,required,unique=NIK"
Nama string json:"nama" validate:"required"
TempatLahir string json:"tempat_lahir"
TanggalLahir string json:"tanggal_lahir"
JenisKelamin string json:"jenis_kelamin"
Alamat string json:"alamat"
Agama string json:"agama"
Pekerjaan string json:"pekerjaan"
}

but my API produces an error like this
"code": "99",
"message": "Validation Error",
"data": {
"NIK": "Key: 'CreateKtpRequest.NIK' Error:Field validation for 'NIK' failed on the 'unique' tag"
}

I have made sure that the data I entered is not duplicated, all tag working normal except unique tag

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions