You are here

public function LDAPAuthorizationProvider::validateRowForm in Lightweight Directory Access Protocol (LDAP) 8.3

Same name and namespace in other branches
  1. 8.4 ldap_authorization/src/Plugin/authorization/Provider/LDAPAuthorizationProvider.php \Drupal\ldap_authorization\Plugin\authorization\Provider\LDAPAuthorizationProvider::validateRowForm()

Validates the authorization form row.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides ConfigurableAuthorizationPluginBase::validateRowForm

File

ldap_authorization/src/Plugin/authorization/Provider/LDAPAuthorizationProvider.php, line 269

Class

LDAPAuthorizationProvider
The LDAP authorization provider for authorization module.

Namespace

Drupal\ldap_authorization\Plugin\authorization\Provider

Code

public function validateRowForm(array &$form, FormStateInterface $form_state) {
  parent::validateRowForm($form, $form_state);
  foreach ($form_state
    ->getValues() as $value) {
    if (isset($value['provider_mappings'])) {
      if ($value['provider_mappings']['is_regex'] == 1) {
        if (@preg_match($value['provider_mappings']['query'], NULL) === FALSE) {
          $form_state
            ->setErrorByName('mapping', t('Invalid regular expression'));
        }
      }
    }
  }
}