Skip to content

square-bit/laravel-pt-rules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

c63db37 · Feb 11, 2025

History

12 Commits
Mar 15, 2021
Feb 11, 2025
Feb 11, 2025
Aug 9, 2024
Feb 11, 2025
Nov 5, 2020
Oct 17, 2022
Nov 5, 2020
Mar 10, 2022
Aug 9, 2024
Nov 5, 2020

Repository files navigation

Set of validation rules relevant for Portugal

Latest Stable Version License Total Downloads

This package provides a set of Rules for Laravel 8 that are mainly useful to validate Portuguese ... stuff .... such as NIFs and CCs.

Installation

Via Composer

$ composer require square-bit/laravel-pt-rules

Usage

Just like any other validation rule, simply add the desired class to the list of rules. Example:

return Validator::make($data, [
    [...]
    'nif' => ['required', new NIF()],
    [...]
]);

Available rules

Class Description
NIF Checks if the input is a valid Portuguese Fiscal ID number. Accepts both with and without the country preffix, ex: '123456789' or 'PT123456789'
CompanyNIF Checks if the input is a valid Portuguese Fiscal ID number for a company (i.e. it starts with 5 or 9). Accepts both with and without the country preffix, ex: '523456789' or 'PT523456789'
BI Checks if the input is a valid Portuguese Identification Card number. (requires the entire number, including the last digit)
CC Checks if the input is a valid Portuguese Citizen Card number. (requires the full number, ex: "12233456 7 ZZ0")

Change log

Please see the changelog for more information on what has changed recently.

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.