Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Credit Card

Credit Card Laravel Package

laravel-validation-rules/credit-card

Laravel validation rules for credit cards: validate card numbers with Luhn, detect major brands, and check expiration dates and CVV codes. Drop-in rules for form requests and validators, with clear error messages and support for common card types.

View on GitHub
Deep Wiki
Context7

Credit Card Validation

Frequently asked questions about Credit Card
How do I install laravel-validation-rules/credit-card in a Laravel app?
Install it with Composer using composer require laravel-validation-rules/credit-card, then pin a compatible constraint such as ^1.12.3 for the non-string input fix. Add the rule to a FormRequest, inline validator, or API request validation path. No database or schema migration is expected.
Which Laravel and PHP versions does this credit card validation package support?
The provided context does not list the exact Laravel and PHP support matrix, so confirm the repository's documented versions and CI coverage before rollout. Pin a compatible ^1.12.3 constraint and review your lockfile and dependency constraints. Validate the rule in one representative endpoint before applying it across the application.
How do I use the credit card rule in a Laravel FormRequest?
Add the package rule to the rules array in your FormRequest or inline validator alongside your other field rules. The package is stateless and low-coupling, so it fits standard Laravel validation flows without extra infrastructure. Test the resulting error messages and API response behavior in your application.
Does this package validate card numbers with Luhn and detect card brands?
Yes. The package provides Laravel validation rules for credit card numbers using Luhn-style checks and detects major card brands. It is intended for input-format validation, not payment authorization, fraud checks, or PCI compliance. Use it alongside your payment gateway SDK and server-side payment flows.
Can it check expiration dates and CVV codes?
Yes. The package includes rules for checking credit card expiration dates and CVV codes in addition to card number and brand validation. These are format and input checks only, so they do not replace gateway-side validation or authorization. Confirm the exact rule names and usage in the repository documentation.
What happens with non-string input like null, arrays, or numbers in version 1.12.3?
Release 1.12.3 changes non-string input to fail validation instead of throwing a TypeError. That improves integration safety for FormRequests and API validation paths where malformed payloads can occur. Add tests for null, arrays, objects, and numeric inputs in your application to confirm the behavior on your supported versions.
Does this package replace payment gateway validation or PCI compliance controls?
No. It is an input-format validation component and should not be treated as a payment-security or PCI-compliance control. It does not replace gateway-side validation, tokenization, fraud checks, or server-side authorization. Document clearly that it validates card input format only.
Are validation errors localized and surfaced through normal Laravel validation messages?
The package is designed as drop-in Laravel validation rules with clear error messages, so failures should surface through normal Laravel validation messaging. Localization and API response formatting should still be verified in your own validation flows. Test the exact error output in a representative FormRequest or API endpoint.
Which card brands and formats are supported, and are they sufficient for my target markets?
The package detects major card brands and supports common card types, but the exact brand and format list should be checked against the repository documentation. Confirm coverage for your target markets before replacing custom regex validation. If a required brand or format is not supported, add custom validation or rely on gateway-side checks.
How should I test and roll out this rule safely?
Add tests for valid cards, invalid cards, and non-string input, asserting validation failures rather than exceptions. If replacing custom regex validation, run both approaches in staging before switching. Roll out to one FormRequest or API endpoint first, then expand after confirming error messages and response behavior.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core