public static function CardCode::numberIsValid in Creditfield Form Element 8
Validation of the value submitted in the creditfield_cardcode field.
Parameters
$value:
Return value
bool
3 calls to CardCode::numberIsValid()
- CardCode::validateCardCode in src/
Element/ CardCode.php - CardCodeTest::testBadCodeValidation in tests/
src/ Unit/ Element/ CardCodeTest.php - @covers ::numberIsValid @dataProvider providerInvalidCardCodeNumbers
- CardCodeTest::testGoodCodeValidation in tests/
src/ Unit/ Element/ CardCodeTest.php - @covers ::numberIsValid @dataProvider providerValidCardCodeNumbers
File
- src/
Element/ CardCode.php, line 91
Class
- CardCode
- Provides a one-line credit card number field form element.
Namespace
Drupal\creditfield\ElementCode
public static function numberIsValid($value) {
// value is not an integer or is an integer but not between 3 and 4 digits
return (bool) preg_match('/^\\d{3,4}$/', $value);
}