Form validation handler.
array $form: An associative array containing the structure of the form.
array $form_state: An associative array containing the current state of the form.
Overrides FormInterface::validateForm
public function validateForm(array &$form, array &$form_state) {
$ip = trim($form_state['values']['ip']);
if ($this->ipManager
->isBanned($ip)) {
form_set_error('ip', t('This IP address is already banned.'));
}
elseif ($ip == $this->request
->getClientIP()) {
form_set_error('ip', t('You may not ban your own IP address.'));
}
elseif (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) == FALSE) {
form_set_error('ip', t('Enter a valid IP address.'));
}
}