laravel-enso/cnpvalidator

This package is abandoned and no longer maintained. The author suggests using the laravel-enso/cnp-validator package instead.

Romanian CNP validator for Laravel

3.1.0 2024-03-29 14:59 UTC

README

Codacy Badge StyleCI License Total Downloads Latest Stable Version

Romanian CNP validator for Laravel

Instalation Steps

  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() == 'PATCH'
                        ? Rule::unique('users', 'nin')->ignore(route('user')->id)
                        : Rule::unique('users', 'nin')
                ],
        ];
    }
    

Notes

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.

Contributions

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

License

This package is released under the MIT license.