laravel-rules maintained by schwarzer
Laravel Rules Package
Installation
You can install the package via composer:
composer require schwarzer/laravel-rules
Usage
Please consider reading the Laravel Docs first.
Have I Been Pwned
In the next major release you'll be able to set the API key by config.
This rule is inspired by valorin/pwned-validator.
Translation
Please add to your /resources/lang/{lang}/validation.php file the following line:
English
'hibp' => 'The :attribute occurs at least :min times in a list of known passwords.',
Deutsch
'hibp' => 'Das :attribute kommt mindestens :min mal in einer Liste bekannter Passwörter vor.',
Short syntax
Validator::make($request->all(), [
'password' => 'required|hibp',
]);
You can specify how often your password (hash) should be found minimum in the HIBP results.
Validator::make($request->all(), [
'password' => 'required|hibp:min=1',
]);
Class / Object syntax
Validator::make($request->all(), [
'password' => ['required', new HaveIBeenPwned],
]);
You can specify how often your password (hash) should be found minimum in the HIBP results.
Validator::make($request->all(), [
'password' => ['required', new HaveIBeenPwned(1)],
]);
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
License
The MIT License (MIT). Please see License File for more information.