# Migrating from PHP (laravel-go-credit-card)

> Use these Go functions and Laravel for Go rules when moving a form from laravel-validation-rules/credit-card.

- Package: laravel-go-credit-card (Laravel for Go, alpha), go modules: `github.com/bowerbird-si/laravel-go-credit-card`
- Maintenance: active; Latest release: 0.1.0 (2026-12-04); Framework: go.laravel.com v0.2.0 or later; Go: Go 1.27 or later; Licence: MIT
- Links: [Repository](https://github.com/bowerbird-si/laravel-go-credit-card), [pkg.go.dev](https://pkg.go.dev/github.com/bowerbird-si/laravel-go-credit-card@v0.1.0), [Changelog](https://oss.bowerbird.si/go-credit-card/docs/changelog/), [Contributing](https://github.com/bowerbird-si/laravel-go-credit-card/blob/516b06ae7d4962972d8cf865beb39b4cfa10a77b/CONTRIBUTING.md), [Security policy](https://github.com/bowerbird-si/laravel-go-credit-card/blob/516b06ae7d4962972d8cf865beb39b4cfa10a77b/SECURITY.md)
- Based on: [laravel-validation-rules/credit-card](https://github.com/laravel-validation-rules/credit-card): The card validation package this independent Go implementation follows, pinned to version 1.12.3.
- PHP parity: full (30 covered, 12 diverged, 0 planned of 42 abilities; 830 fixtures; follows laravel-validation-rules/credit-card 1.12.3; verified 2026-12-04)
- Community package, not affiliated with Laravel.
- HTML version: https://oss.bowerbird.si/go-credit-card/docs/migrating-from-php/
- Source: https://github.com/bowerbird-si/laravel-go-credit-card/blob/516b06ae7d4962972d8cf865beb39b4cfa10a77b/docs/migrating-from-php.md

Use these Go functions and Laravel for Go rules when moving a form from laravel-validation-rules/credit-card.

| PHP | Go |
| --- | --- |
| `Factory::makeFromNumber($number)` | `creditcard.Parse(number)` |
| `new Visa($number)` | Look up `creditcard.BrandNamed("visa")`, then call `brand.Parse(number)` |
| `CardNumber` | `creditcard.Number()` |
| `CardCvc` | `creditcard.CVC()` or `creditcard.CVCFrom("number")` |
| `CardExpirationYear` | `creditcard.ExpirationYear()` |
| `CardExpirationMonth` | `creditcard.ExpirationMonth()` |
| `CardExpirationDate('m/y')` | `creditcard.ExpirationDate("m/y")` |
| `ExpirationDateValidator::validate` | `creditcard.ValidExpiration(year, month, now)` |
| `MSG_*` | `creditcard.Key*` constants |

To pass a companion value directly, use `CVCFor(number)`, `ExpirationYearFor(month)` or
`ExpirationMonthFor(year)`.

Add `rule.Required` to mandatory fields. Laravel for Go skips these rules on missing, null and blank
fields. Configure [`DontFlash`](https://oss.bowerbird.si/go-credit-card/docs/getting-started/#keep-card-fields-out-of-old-input) for every card
number and CVC field before accepting checkout form submissions.

The Go rule messages default to English. Use `Message` or `MessageFor` with an exported `Key*`
constant if your application expects translation keys. Parsing strips ASCII whitespace before
brand recognition. Validation failures expose a fixed category or message without submitted values.
