Skip to content

SchwarzerIT/laravel-rules

Repository files navigation

Laravel Rules Package

Latest Version on Packagist Build Status Code Coverage Total Downloads License

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

haveibeenpwned.com API v3

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.