public static function YamlFormCreditCardNumber::validateYamlFormCreditCardNumber in YAML Form 8
Form element validation handler for #type 'creditcard_number'.
File
- src/
Element/ YamlFormCreditCardNumber.php, line 50
Class
- YamlFormCreditCardNumber
- Provides a form element for entering a credit card number.
Namespace
Drupal\yamlform\ElementCode
public static function validateYamlFormCreditCardNumber(&$element, FormStateInterface $form_state, &$complete_form) {
$value = trim($element['#value']);
$form_state
->setValueForElement($element, $value);
if ($value !== '' && !self::validCreditCardNumber($value)) {
$form_state
->setError($element, t('The credit card number is not valid.'));
}
}