Weave Code
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

Laravel Spanish Validator Laravel Package

danielmrdev/laravel-spanish-validator

View on GitHub
Deep Wiki
Context7

Laravel validator for spanish stuff: NIF, NIE, CIF, NSS, IBAN, Postal Code, Phone numbers

Latest Version on Packagist Tests Code Quality Total Downloads

This package is a set of diferent validation rules for spanish national id numbers like:

  • NIF: "Número de Identificación Fiscal" (tax number for individuals).
  • NIE: "Número de Idenfiticación para Extranjeros" (identity number for foreigners).
  • CIF: "Código de Identificación Fiscal" (tax number for companies).
  • NSS: "Número de la Seguridad Social" (national security number).

Also the package include validators for:

  • IBAN: International Bank Account Number.
  • Postal codes: Spanish postal codes.
  • Phone number: Spanish phone numbers format.

Installation

The package can be installed via composer:

composer require danielmrdev/laravel-spanish-validator

The package will automatically register itself.

If you want to edit the validation messages, you should run the following command to publish the translation files into your resources/lang folder:

php artisan vendor:publish --provider="Danielmrdev\SpanishValidator\SpanishValidatorServiceProvider"

Migration from v1 (orumad/laravel-spanish-validator)

v2.0.0 is a major version with breaking changes:

  1. Package name: orumad/laravel-spanish-validatordanielmrdev/laravel-spanish-validator
  2. Namespace: Orumad\SpanishValidatorDanielmrdev\SpanishValidator

To upgrade:

# Update composer.json
composer require danielmrdev/laravel-spanish-validator:^2.0

# Update your code imports
# Old: use Orumad\SpanishValidator\Validator;
# New: use Danielmrdev\SpanishValidator\Validator;

# Update Laravel service provider references if custom published
# Old: Orumad\SpanishValidator\SpanishValidatorServiceProvider
# New: Danielmrdev\SpanishValidator\SpanishValidatorServiceProvider

The validation rules remain the same, only the namespace has changed.

Available rules

nif

Determine if the input is a valid "Número de Identificación Fiscal" (tax number for individuals).

nie

Determine if the field under validation is a valid "Número de Idenfiticación para Extranjeros" (identity number for foreigners).

cif

This rule will validate if the input field is a valid "Código de Identificación Fiscal" (tax number for companies).

spanish_tax_number

This rule validates if the input is a valid spanish tax number: NIF or NIE or CIF.

spanish_personal_id

Will validate if the input is a valid personal id number in Spain (NIF or NIE).

nss

Determine if the field under validation is a valid "Número de la Seguridad Social"_ (national security number).

iban

Test if the input field is a valid IBAN bank account number. (This uses the package globalcitizen/php-iban to check the validity of IBAN)

spanish_postal_code

Will check if the postal code is a valid spanish postal code.

spanish_phone

This tule validates if the input field content is a valid spanish phone number format.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email hello@danielmr.dev instead of using the issue tracker.

License

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

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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope