diff --git a/megaport/common.go b/megaport/common.go index 347bc67..74ecaf7 100644 --- a/megaport/common.go +++ b/megaport/common.go @@ -45,14 +45,14 @@ func resourceMegaportVxcEndElem() *schema.Resource { } func validateCIDRAddress(v interface{}, k string) (warns []string, errs []error) { - vv := v.(string) - _, ipnet, err := net.ParseCIDR(vv) - if err != nil { - errs = append(errs, fmt.Errorf("%q is not a valid CIDR: %s", k, err)) + vv, ok := v.(string) + if !ok { + errs = append(errs, fmt.Errorf("expected type of %s to be string", k)) return } - if ipnet == nil || vv != ipnet.String() { - errs = append(errs, fmt.Errorf("%q is not a valid CIDR", k)) + _, _, err := net.ParseCIDR(vv) + if err != nil { + errs = append(errs, fmt.Errorf("expected %q to be a valid IPv4 CIDR, got %v: %v", k, vv, err)) } return }