public function validate($attribute, $value, array $parameters, $validator)
    {
        $data = $validator->getData();

        list(
            $countries,
            $types,
            $detect,
            $lenient) = $this->extractParameters($attribute, $parameters, $data);

        // A "null" country is prepended:
        // 1. In case of auto-detection to have the validation run first without supplying a country.
        // 2. In case of lenient validation without provided countries; we still might have some luck...
        if ($detect || ($lenient && empty($countries))) {
            array_unshift($countries, null);
        }

        foreach ($countries as $country) {
            try {
                // Parsing the phone number also validates the country, so no need to do this explicitly.
                // It'll throw a PhoneCountryException upon failure.
                $phoneNumber = PhoneNumber::make($value, $country);

                // Type validation.
                if (! empty($types) && ! $phoneNumber->isOfType($types)) {
                    continue;
                }

                $lenientPhoneNumber = $phoneNumber->lenient()->getPhoneNumberInstance();

                // Lenient validation.
                if ($lenient && $this->lib->isPossibleNumber($lenientPhoneNumber, $country)) {
                    return true;
                }

                $phoneNumberInstance = $phoneNumber->getPhoneNumberInstance();

                // Country detection.
                if ($detect && $this->lib->isValidNumber($phoneNumberInstance)) {
                    return true;
                }

                // Default number+country validation.
                if ($this->lib->isValidNumberForRegion($phoneNumberInstance, $country)) {
                    return true;
                }
            } catch (NumberParseException $e) {
                continue;
            }
        }

        return false;
    }