You are here

function _commerce_mollie_api_key_element_validate in Commerce Mollie 7

Validates the entered Mollie live and test API keys.

Parameters

$element: The form element

$form_state: The form state

$form: The form

1 string reference to '_commerce_mollie_api_key_element_validate'
commerce_mollie_settings_form in ./commerce_mollie.module
Implements hook_commerce_settings_form().

File

./commerce_mollie.module, line 456

Code

function _commerce_mollie_api_key_element_validate($element, &$form_state, $form) {
  if ($element['#title'] == 'Mollie live API key' && strpos($element['#value'], 'live') !== 0) {
    form_error($element, t('Your Mollie live API key should start with <em>live</em>.'));
  }
  else {
    if ($element['#title'] == 'Mollie test API key' && strpos($element['#value'], 'test') !== 0) {
      form_error($element, t('Your Mollie test API key should start with <em>test</em>.'));
    }
  }
}