public function Ip2CountrySettingsForm::validateIp in IP-based Determination of a Visitor's Country 8
Element validation handler for IP address input.
File
- src/
Form/ Ip2CountrySettingsForm.php, line 378
Class
- Ip2CountrySettingsForm
- Configure ip2country settings for this site.
Namespace
Drupal\ip2country\FormCode
public function validateIp($element, FormStateInterface $form_state) {
$ip_address = $element['#value'];
if (!filter_var($ip_address, FILTER_VALIDATE_IP)) {
$form_state
->setError($element, $this
->t('The IP address you entered is invalid. Please enter an address in the form xxx.xxx.xxx.xxx where xxx is between 0 and 255 inclusive.'));
}
}