v1.3.0
This commit is contained in:
@@ -12,7 +12,7 @@ func errorMessage(fe validator.FieldError) string {
|
||||
|
||||
switch fe.Tag() {
|
||||
|
||||
// Default Validators
|
||||
// Common Validators
|
||||
case "required":
|
||||
return fmt.Sprintf("%s %s is required", prefix, fe.Field())
|
||||
case "gt":
|
||||
@@ -26,13 +26,31 @@ func errorMessage(fe validator.FieldError) string {
|
||||
case "email":
|
||||
return fmt.Sprintf("%s %s: unexpected E-Mail format", prefix, fe.Field())
|
||||
|
||||
// Account Validators
|
||||
case "accountAccessType":
|
||||
return fmt.Sprintf("%s %s must be one of the followng: %s",
|
||||
case "driver":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(accountAccessTypeValues))
|
||||
joinValues(driverValues))
|
||||
|
||||
case "accessType":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(accessTypeValues))
|
||||
|
||||
case "resTypes":
|
||||
return fmt.Sprintf("%s %s can contain only the following values: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(resTypesValues))
|
||||
|
||||
case "proto":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(protoValues))
|
||||
|
||||
// Account Validators
|
||||
case "accountCUType":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
@@ -40,12 +58,6 @@ func errorMessage(fe validator.FieldError) string {
|
||||
joinValues(accountCUTypeValues))
|
||||
|
||||
// BService Validators
|
||||
case "bserviceDriver":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(bserviceDriverValues))
|
||||
|
||||
case "bserviceMode":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
@@ -83,14 +95,68 @@ func errorMessage(fe validator.FieldError) string {
|
||||
fe.Field(),
|
||||
joinValues(computeNetTypeValues))
|
||||
|
||||
case "computeProto":
|
||||
case "computeOrder":
|
||||
return fmt.Sprintf("%s %s can contain only the following values: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(computeOrderValues))
|
||||
|
||||
case "computeDataDisks":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(computeProtoValues))
|
||||
joinValues(computeDataDisksValues))
|
||||
|
||||
// Disk Validators
|
||||
case "diskType":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(diskTypeValues))
|
||||
|
||||
// Flipgroup Validators
|
||||
case "flipgroupClientType":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(flipgroupClientTypeValues))
|
||||
|
||||
// KVM_X86/KVM_PPC Validators
|
||||
case "kvmNetType":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(kvmNetTypeValues))
|
||||
|
||||
// LB Validators
|
||||
case "lbAlgorithm":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(lbAlgorithmValues))
|
||||
|
||||
// RG Validators
|
||||
case "rgDefNet":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(rgDefNetValues))
|
||||
|
||||
case "rgNetType":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(rgNetTypeValues))
|
||||
|
||||
// ViNS Validators
|
||||
case "vinsType":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(vinsTypeValues))
|
||||
|
||||
// Image Validators
|
||||
case "bootType":
|
||||
case "imageBootType":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
@@ -114,6 +180,13 @@ func errorMessage(fe validator.FieldError) string {
|
||||
fe.Field(),
|
||||
joinValues(imageArchitectureValues))
|
||||
|
||||
// SEP Validators
|
||||
case "sepFieldType":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(sepFieldTypeValues))
|
||||
|
||||
}
|
||||
|
||||
return fe.Error()
|
||||
|
||||
Reference in New Issue
Block a user