Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Sahrule Laravel Package

raditzfarhan/sahrule

View on GitHub
Deep Wiki
Context7

SahRule

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.

Rule Description Example
Base64Image Validate a base64 image string. Pre-defined allowed image types are jpg, jpeg, png, gif, bmp and tiff. new Base64Imagenew Base64Image('jpg', 'png')
Base64MaxImageSize Validate a base64 image size. Default max size is 2 MB. Pass your own max size in byte (B). new Base64MaxImageSizenew Base64MaxImageSize(500)

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
andydefer/laravel-task
helgesverre/toon
symfony/ai-mate
f1monkey/eve-esi-bundle
f-froehlich/symfony-validator
f-froehlich/api
ezsystems/templated-uri-bundle
ezsystems/stash-bundle
ezsystems/share-buttons-bundle
ezsystems/privacy-cookie-bundle
ezsystems/payment-paypal-bundle
ezsystems/payment-core-bundle
ezsystems/job-queue-bundle
ezsystems/hybrid-platform-ui
ezsystems/ezmigrationbundle
ezsystems/ezcommerce-econtent-installer
ezsystems/comment-bundle
ezsystems/apache-tika-bundle
ezar101/easyadmin-trix-extension-bundle
eyerim/oauth2-azure-bundle