Search by

aindot / extra-rules

aindot

A package that include extra rules for Laravel, Kuwait Civil ID validation, ISBN10, ISBN13 and more in development.

v1.6 2026-10-29 18:37 UTC

This package is auto-updated.

Last update: 2026-11-05 07:08:46 UTC


README

A package that include extra validation rules for Laravel, this package approach focuses on actual usage, for example the ISBN test must validate against different real-world examples.

The following are the validation rules that are in development or have been developed.

  • Kuwaiti Civil ID - Official personal identification number for residents of Kuwait.
  • ISBN10 - Legacy 10-character identifier for books.
  • ISBN13 - Modern 13-digit identifier for books and related media.
  • ISNI - Unique identifier for authors, artists, and other contributors.
  • ISWC - Unique identifier for compositions.
  • ISTC - Unique identifier for textual works across editions and formats.
  • ISAN - Unique identifier for films, TV programmes, and audiovisual works.
  • ISMN - Unique identifier for printed composition publications.
  • ISRC - Unique identifier for sound recordings and sound videos.
  • URN - Persistent, location-independent uniform resource name.
  • NBN - National bibliography number used by national libraries.
  • DOI - Persistent identifier for digital objects such as papers and datasets.
  • ISSN - Unique identifier for serial publications such as journals.
  • EAN8 - 8-digit retail barcode for small product packaging.
  • EAN13 - 13-digit retail barcode used worldwide at point of sale.
  • Email - RFC 5322 compliant email address validation.
  • GTIN13 - 13-digit global trade item number for products and packaging.
  • IMEI - Unique identifier for a mobile handset or cellular device.
  • IMEISV - Device identity plus software version number (SVN).
  • IMSI - A unique identifier for a mobile network subscriber.
  • ICCID - A unique serial number identifying a sim card.
  • MEID - Unique identifier for CDMA mobile devices.
  • ESN - Legacy electronic serial number for older CDMA devices.
  • MAC address - Unique hardware address for a network interface.
  • E.164 - International telephone number including country code.
  • IBAN - Cross-border bank account identifier.
  • BIC/SWIFT - Bank identifier code used in financial transfers.
  • Credit card - Payment card number validated with Luhn.
  • CVV - 3- or 4-digit card security code.
  • UPC-A - 12-digit North American retail product barcode.
  • GTIN14 - 14-digit trade item number for cases and pallets.
  • SSCC - Serial shipping container code for logistics units.
  • VIN - 17-character vehicle identification number.
  • CPF - Brazilian individual taxpayer registry number.
  • CNPJ - Brazilian company taxpayer registry number.
  • SSN - US Social Security Number format check.
  • Passport MRZ - TD3 passport machine-readable zone line check.
  • UUID - Universally unique identifier in 8-4-4-4-12 form.
  • ULID - 26-character lexicographically sortable unique ID.
  • JWT - JSON Web Token header.payload.signature structure.
  • Hex color - CSS hexadecimal color value.
  • Slug - URL-friendly lowercase hyphenated string.
  • Emirates ID - Official 15-digit UAE identity number.
  • Iqama - Saudi 10-digit national ID or resident Iqama number.
  • Egyptian NID - Egyptian 14-digit national identity number.
  • UPC-E - Compressed UPC barcode for small retail packages.
  • GTIN8 - 8-digit global trade item number for small products.
  • ITF-14 - 14-digit carton barcode using GTIN-14 structure.
  • Private key - PEM private key blocks (RSA, EC, OpenSSH, PGP, and more).
  • API key - Known service API key prefixes (AWS, Stripe, GitHub, and more).
  • Bearer token - HTTP Bearer authorization token format.

Installation

You can install the package via composer:

composer require aindot/extra-rules

Translations

English and Arabic validation messages are included. Publish them if you want to customize the wording:

php artisan vendor:publish --tag=extra-rules-translations

Set the app locale to use Arabic messages:

app()->setLocale('ar');

Usage

    $data = [
        'KuwaitiId' => $id,
    ];

    $validator = Validator::make($data, [
        'KuwaitiId' => [new KuwaitCivilId],
    ]);

Magic guess

    use Aindot\ExtraRules\ExtraRules;
    use Aindot\ExtraRules\RuleType;

    $matches = (new ExtraRules)->magic('4111111111111111');
    // all matching RuleType cases

    $matches = (new ExtraRules)->magic('4111111111111111', ['credit_card', RuleType::Imei]);
    // only test the provided candidates
php artisan extra-rules:magic "4111111111111111"
php artisan extra-rules:magic "4111111111111111" --rules=credit_card,imei

Values that start with - are parsed as options, so separate them with --:

php artisan extra-rules:magic --rules=private_key -- "$(cat id_openssh)"

For secrets, call the API in code instead of passing them as CLI arguments. Arguments are visible in shell history and the process list, and a misparsed value can end up in storage/logs/laravel.log:

$matches = (new ExtraRules)->magic($privateKey);

Redact secrets

Detect and redact secrets inside arbitrary text. Returns metadata only, never the secret values:

    use Aindot\ExtraRules\ExtraRules;

    $clean = (new ExtraRules)->redact($text);

    $findings = (new ExtraRules)->detect($text);
    // [['type' => RuleType::CreditCard, 'offset' => 12, 'length' => 16], ...]

Supported types: iban, api_key, bearer_token, jwt, kuwait_civil_id, credit_card, and private_key. Detected values are replaced with [REDACTED:<type>]; overlapping matches keep the longest one (for example Bearer <jwt> is redacted once as bearer_token).

php artisan extra-rules:redact --file=log.txt
cat log.txt | php artisan extra-rules:redact --stdin
php artisan extra-rules:redact "card 4111111111111111"
php artisan extra-rules:redact --file=log.txt --types=iban,credit_card
php artisan extra-rules:redact --file=log.txt --list

--list prints counts per type without the redacted text. Prefer --file or --stdin for input that contains secrets.

Note: 13-digit EAN/ISBN values can pass the Luhn check and are reported as credit_card.

Generate samples

    use Aindot\ExtraRules\ExtraRules;
    use Aindot\ExtraRules\RuleType;

    $imei = (new ExtraRules)->generate('imei');
    $ibans = (new ExtraRules)->generateMany(RuleType::Iban, 5);
php artisan extra-rules:generate imei
php artisan extra-rules:generate iban --count=5

Email validation and generation

    use Aindot\ExtraRules\ExtraRules;
    use Aindot\ExtraRules\RuleType;

    $validator = Validator::make($data, [
        'email' => [new \Aindot\ExtraRules\Rules\Email],
    ]);

    $email = (new ExtraRules)->generate('email');
    $emails = (new ExtraRules)->generateMany(RuleType::Email, 5);
php artisan extra-rules:generate email
php artisan extra-rules:generate email --count=5

Issues

  • Google Shopping product ID's may be detected as credit cards while using the REDACTED function.

Credits

License

The MIT License (MIT). Please see License File for more information.