You are here

function telephone_validation_element_info_alter in Telephone Validation 8.2

Implements hook_element_info_alter().

File

./telephone_validation.module, line 14
Validate telephone number.

Code

function telephone_validation_element_info_alter(array &$types) {

  // Retrieve configuration entity.
  $config = \Drupal::config('telephone_validation.settings');

  // Adds default validation settings to telephone element.
  // This is just for convenience and to improve DX. You can override following
  // settings at any time on form definition level.
  $types['tel']['#element_validate_settings'] = [
    'format' => $config
      ->get('format') ?: PhoneNumberFormat::E164,
    'country' => $config
      ->get('country') ?: [],
  ];
}