NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages
QR for Laravel

Validation rules & cast

Four validation rules with translated messages:

use RoundlyConsulting\Qr\Enums\ErrorCorrection;
use RoundlyConsulting\Qr\Rules\{Bic, CreditorReference, FitsInQrCode, Iban};

$request->validate([
    'iban' => ['required', new Iban],                   // new Iban(eeaOnly: true)
    'bic' => ['nullable', new Bic],
    'reference' => ['nullable', new CreditorReference],
    'text' => ['required', new FitsInQrCode(ErrorCorrection::Medium, maxVersion: 13)],
]);
  • Iban — a valid IBAN; new Iban(eeaOnly: true) also requires a country of the European Economic Area.
  • Bic — a valid BIC.
  • CreditorReference — a valid ISO 11649 RF reference.
  • FitsInQrCode(?ErrorCorrection $errorCorrection = null, ?int $maxVersion = null, Segmentation $segmentation = Optimal) — Qr::fits() as a validation rule: unset arguments take the configured level, maximum version, ECI policy and kanji switch (explicit arguments win), so it never passes text the encoder then rejects. Use it on any route that renders user input.

AsIban cast

Store IBANs as strings in electronic form and read them back as Iban objects. Invalid input throws:

use RoundlyConsulting\Qr\Casts\AsIban;

protected function casts(): array
{
    return ['iban' => AsIban::class];   // column stores "SK4611…", attribute is an Iban
}

Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

More ways to support, including crypto

By donating, you agree to our donation terms.

Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.