mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
validators: set xx_id when possible
This commit is contained in:
@@ -576,9 +576,13 @@ func (v *ValidatorModelIdOrName) Validate(data *jsonutils.JSONDict) error {
|
||||
if v.Model != nil {
|
||||
val = v.Model.GetId()
|
||||
}
|
||||
if len(v.modelIdKey) > 0 && data.Contains(v.Key) {
|
||||
data.Remove(v.Key)
|
||||
data.Set(v.modelIdKey, jsonutils.NewString(val))
|
||||
if v.modelIdKey != "" {
|
||||
if data.Contains(v.Key) {
|
||||
data.Remove(v.Key)
|
||||
}
|
||||
if val != "" {
|
||||
data.Set(v.modelIdKey, jsonutils.NewString(val))
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user