This is a Set of Amazing Laravel Validation Rules for Credit Cards that will validate that a given credit card number, expiration date, or CVC is valid. As FormRequest ['required', new CardNumber], 'expiration_year' => ['required', new CardExpirationYear($this->get('expiration_month'))], 'expiration_month' => ['required', new CardExpirationMonth($this->get('expiration_year'))], 'cvc' => ['required', new CardCvc($this->get('card_number'))]]; }} // CardExpirationYear requires card expiration month $request->validate(['expiration_year' => '2017'], ['expiration_year' => ['required', new LVR\CreditCard\CardExpirationYear($request->get('expiration_month'))]]); // CardExpirationMonth requires card expiration year $request->validate(['expiration_month' => '11'], ['expiration_month' => ['required', new LVR\CreditCard\CardExpirationMonth($request->get('expiration_year'))]]); // CardExpirationDate requires date format $request->validate(['expiration_date' => '02-18'], ['expiration_date' => ['required', new LVR\CreditCard\CardExpirationDate('my')]]); Directly LVR\CreditCard\Cards\ExpirationDateValidator( $expiration_year, $expiration_month )->isValid(); // Or static LVR\CreditCard\Cards\ExpirationDateValidator::validate( $expiration_year, $expiration_month ); // CardCvc requires card number to determine allowed cvc length $request->validate(['cvc' => '123'], ['cvc' => new LVR\CreditCard\CardCvc($request->get('card_number'))]); Directly LVR\CreditCard\Cards\Card::isValidCvcLength($cvc); For more details, Please visit https://github.com/laravel-validation-rules/credit-card.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners