phillarmonic/pixicato-bundle

A Symfony bundle for validating Brazilian PIX keys.

Installs: 5 175

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 1

Open Issues: 2

Type:symfony-bundle

1.0.2 2024-10-04 11:20 UTC

This package is auto-updated.

Last update: 2025-05-05 10:16:24 UTC


README

A Symfony bundle for validating Brazilian PIX keys.

Pluck the right key every time :)

Installation

composer require phillarmonic/pixicato-bundle

Usage

Validating a PIX key

use Phillarmonic\PIXicato\PixKey;

$pixKey = new PixKey('example@email.com');
if ($pixKey->isValid()) {
    echo "Valid PIX key of type: " . $pixKey->getType()->value;
} else {
    echo "Invalid PIX key";
}

// You can do it in a one-liner too
echo (new PixKey('example@example.com'))->isValid() ? 'Valid' : 'Invalid';

Using the Symfony validator

use Phillarmonic\PIXicato\Validator\Constraints as PIXAssert;

class User
{
    #[PIXAssert\ValidPixKey(
        message: 'This is not a valid PIX key.',
        expectedType: 'email'
    )]
    private string $pixKey;

    // ...
}

Supported PIX key types

  • CPF
  • CNPJ
  • Email
  • Phone number

License

This library is released under the MIT License. See the bundled LICENSE file for details.