raditzfarhan/sahrule

Missing Laravel validation rules.

Installs: 113

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:laravel-package

v1.0.1 2020-05-05 17:52 UTC

This package is auto-updated.

Last update: 2024-12-19 16:26:17 UTC


README

Latest Stable Version Total Downloads License StyleCI

This package provides missing Laravel validation rules.

Installation

Via Composer

$ composer require raditzfarhan/sahrule

Usage

Import validation classes that you need and use it in Laravel validate function as you normally would. Example usage as below snippet:

use RaditzFarhan\SahRule\Rules\Base64Image;

...

// will accept pre-defined allowed image types
$validatedData = $request->validate([
    'image' => ['required', new Base64Image]
]);

// specify allowed image types
$validatedData = $request->validate([
    'image' => ['required', new Base64Image('png', 'gif')]
]);

Use array instead of pipe-delimited string.

Available Rules

All rules are under RaditzFarhan\SahRule\Rules namespace.

Validation Message

All rules come with a default validation message that was pre-defined by the package. If you need to write your own custom message, you can overwrite in in validation.php file that typically can be found at resources/lang/en folder.

The validation key is the rule class name in snake case format. For example for Base64Image rule, the key is base64_image. Snippet as below:

return [
    ...
    'base64_image' => 'Your custom validation message here.',
    ...
];

Change log

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

Credits

License

MIT. Please see the license file for more information.