laravel-enso/cnp-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codacy BadgeStyleCILicenseTotal DownloadsLatest Stable Version

Romanian CNP validator for Laravel

  1. Add 'LaravelEnso\CnpValidator\CnpValidatorServiceProvider::class' to your providers list in config/app.php.

  2. Use the CNP validator in your ValidateModelRequest validation class

    public function rules()
    {
        return [
            'cnp' => [
                    'max:13',
                    'cnp',
                    'nullable',
                    request()->getMethod() == ''
                        ? Rule::unique('users', 'nin')->ignore(route('user')->id)
                        : Rule::unique('users', 'nin')
                ],
        ];
    }
    

Don't forget to add the translation for the validator error message in resources/lang/**/validation.php under the cnp key.

The Laravel Enso Core package comes with this package included.

are welcome. Pull requests are great, but issues are good too.

This package is released under the MIT license.