mirror of
https://github.com/Respect/Validation.git
synced 2026-03-15 14:55:44 +01:00
Introduces a Markdown linter for checking the Changelog format. "See Also" was transformed into a section to make it easier to handle it with the `Content` class. The "Related" linter was simplified to reflect that change too. An additional "alignment" parameter was added to markdown table generators, allowing the padding and headers to be explicitly marked with a specific left (-1), middle (0) or right(1) alignment. Existing files were fixed using the `fix` option after the changes.
3.1 KiB
3.1 KiB
CreditCard
CreditCard()CreditCard(string $brand)
Validates a credit card number.
v::creditCard()->assert('5376 7473 9720 8720');
// Validation passes successfully
v::creditCard()->assert('5376-7473-9720-8720');
// Validation passes successfully
v::creditCard()->assert('5376.7473.9720.8720');
// Validation passes successfully
v::creditCard('American Express')->assert('340316193809364');
// Validation passes successfully
v::creditCard('Diners Club')->assert('30351042633884');
// Validation passes successfully
v::creditCard('Discover')->assert('6011000990139424');
// Validation passes successfully
v::creditCard('JCB')->assert('3566002020360505');
// Validation passes successfully
v::creditCard('MasterCard')->assert('5376747397208720');
// Validation passes successfully
v::creditCard('Visa')->assert('4024007153361885');
// Validation passes successfully
v::creditCard('RuPay')->assert('6062973831636410');
// Validation passes successfully
The current supported brands are:
- American Express (
'American_Express'orCreditCard::AMERICAN_EXPRESS) - Diners Club (
'Diners_Club'orCreditCard::DINERS_CLUB) - Discover (
'Discover'orCreditCard::DISCOVER) - JCB (
'JCB'orCreditCard::JCB) - Mastercard (
'American_Express'orCreditCard::MASTERCARD) - Visa (
'Visa'orCreditCard::VISA) - RuPay (
'RuPay'orCreditCard::RUPAY)
It ignores any non-numeric characters, use Digit, Spaced, or Regex when appropriate.
v::digit()->creditCard()->assert('5376747397208720');
// Validation passes successfully
Templates
CreditCard::TEMPLATE_STANDARD
| Mode | Template |
|---|---|
default |
{{subject}} must be a valid credit card number |
inverted |
{{subject}} must not be a valid credit card number |
CreditCard::TEMPLATE_BRANDED
| Mode | Template |
|---|---|
default |
{{subject}} must be a valid {{brand|raw}} credit card number |
inverted |
{{subject}} must not be a valid {{brand|raw}} credit card number |
Template placeholders
| Placeholder | Description |
|---|---|
brand |
|
subject |
The validated input or the custom validator name (if specified). |
Categorization
- Banking
Changelog
| Version | Description |
|---|---|
| 2.2.4 | RuPay is now supported as a brand |
| 1.1.0 | Allow the define credit card brand |
| 0.3.9 | Created |