You are here

public function ShadowboxGlobalSettingsForm::validateHexColor in Shadowbox 8

Validate a hex color value.

Parameters

$input: The string to validate.

Return value

TRUE if $input is a valid hex color value (e.g. 000 or 000000)

1 call to ShadowboxGlobalSettingsForm::validateHexColor()
ShadowboxGlobalSettingsForm::validateForm in lib/Drupal/shadowbox/Form/ShadowboxGlobalSettingsForm.php
Implements \Drupal\Core\Form\FormInterface::validateForm().

File

lib/Drupal/shadowbox/Form/ShadowboxGlobalSettingsForm.php, line 26
Contains \Drupal\shadowbox\Form\ShadowboxGlobalSettingsForm.

Class

ShadowboxGlobalSettingsForm
Configure the settings for Shadowbox.

Namespace

Drupal\shadowbox\Form

Code

public function validateHexColor($input, $long = FALSE) {
  if ($long == TRUE) {
    return preg_match('!^[a-f0-9]{6}$!i', $input);
  }
  else {
    return preg_match('!^[a-f0-9]{3}([a-f0-9]{3})?$!i', $input);
  }
}