add new api
This commit is contained in:
@@ -194,6 +194,30 @@ func registerCustomFieldTranslations(validate *validator.Validate, trans ut.Tran
|
||||
t, _ := ut.T("auth_date", getFieldDisplayName(fe.Field()))
|
||||
return t
|
||||
})
|
||||
|
||||
// 授权书URL翻译
|
||||
validate.RegisterTranslation("authorization_url", trans, func(ut ut.Translator) error {
|
||||
return ut.Add("authorization_url", "{0}必须是有效的URL地址,且文件类型必须是PDF、JPG、JPEG、PNG或BMP格式", true)
|
||||
}, func(ut ut.Translator, fe validator.FieldError) string {
|
||||
t, _ := ut.T("authorization_url", getFieldDisplayName(fe.Field()))
|
||||
return t
|
||||
})
|
||||
|
||||
// 唯一标识翻译
|
||||
validate.RegisterTranslation("validUniqueID", trans, func(ut ut.Translator) error {
|
||||
return ut.Add("validUniqueID", "{0}格式不正确,只能包含字母、数字、下划线和连字符,且长度不能超过32位", true)
|
||||
}, func(ut ut.Translator, fe validator.FieldError) string {
|
||||
t, _ := ut.T("validUniqueID", getFieldDisplayName(fe.Field()))
|
||||
return t
|
||||
})
|
||||
|
||||
// 回调地址翻译
|
||||
validate.RegisterTranslation("validReturnURL", trans, func(ut ut.Translator) error {
|
||||
return ut.Add("validReturnURL", "{0}必须是有效的URL地址,且长度不能超过500字符", true)
|
||||
}, func(ut ut.Translator, fe validator.FieldError) string {
|
||||
t, _ := ut.T("validReturnURL", getFieldDisplayName(fe.Field()))
|
||||
return t
|
||||
})
|
||||
}
|
||||
|
||||
// getFieldDisplayName 获取字段显示名称(中文)
|
||||
@@ -210,7 +234,10 @@ func getFieldDisplayName(field string) string {
|
||||
"email": "邮箱",
|
||||
"enterprise_email": "企业邮箱",
|
||||
"enterprise_address": "企业地址",
|
||||
"ip_address": "IP地址",
|
||||
"ip": "IP地址",
|
||||
"auth_date": "授权日期",
|
||||
"unique_id": "唯一标识",
|
||||
"return_url": "回调地址",
|
||||
"display_name": "显示名称",
|
||||
"scene": "使用场景",
|
||||
"Password": "密码",
|
||||
@@ -252,6 +279,8 @@ func getFieldDisplayName(field string) string {
|
||||
"VerificationCode": "验证码",
|
||||
"contract_url": "合同URL",
|
||||
"ContractURL": "合同URL",
|
||||
"authorization_url": "授权书地址",
|
||||
"AuthorizationURL": "授权书地址",
|
||||
"amount": "金额",
|
||||
"Amount": "金额",
|
||||
"balance": "余额",
|
||||
@@ -279,8 +308,6 @@ func getFieldDisplayName(field string) string {
|
||||
"ID": "ID",
|
||||
"ids": "ID列表",
|
||||
"IDs": "ID列表",
|
||||
"auth_date": "授权日期",
|
||||
"AuthDate": "授权日期",
|
||||
"id_card": "身份证号",
|
||||
"IDCard": "身份证号",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user