Download the PHP package kentjerone/laravel-chain-rule without Composer
On this page you can find all versions of the php package kentjerone/laravel-chain-rule. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download kentjerone/laravel-chain-rule
More information about kentjerone/laravel-chain-rule
Files in kentjerone/laravel-chain-rule
Download kentjerone/laravel-chain-rule
More information about kentjerone/laravel-chain-rule
Files in kentjerone/laravel-chain-rule
Vendor kentjerone
Package laravel-chain-rule
Short Description A chainable rule builder for Laravel validation.
License MIT
Package laravel-chain-rule
Short Description A chainable rule builder for Laravel validation.
License MIT
Please rate this library. Is it a good library?
Informations about the package laravel-chain-rule
Laravel ChainRule
A chainable validation rule builder for Laravel.
Simplifies writing complex validation rules by chaining methods together in a fluent, readable API .
Features
- Chain simple rules :
required(),nullable(),email(),string(),integer(), etc. - Chain parameterized rules :
between(),after(), etc. - Conditional rules :
addIfTrue($condition, $rule)– adds the rule if the condition istrueaddIfFalse($condition, $rule)– adds the rule if the condition isfalseaddIfNull($value, $rule)– adds the rule if the value isnulladdIfNotNull($value, $rule)– adds the rule if the value is notnulladdIfEmpty($value, $rule)– adds the rule if the value is empty (null,[],'',0,false, or empty object)addIfNotEmpty($value, $rule)– adds the rule if the value is not emptyaddWhen(callable $callback, $rule)– adds the rule if the callback returnstrue
- Security helpers:
stripTags(array $allowedHtmlTags)– validates that the field contains only the given safe tags (all others are rejected).sanitizeXss(array $allowedHtmlTags)– blocks malicious content like<script>,onerror=,javascript:links, andalert()while allowing safe tags.
- Automatic deduplication of rules to prevent duplicates when chaining or merging.
- Returns rules as array (
toArray()) or string (toString()).
Installation
Install via Composer:
Usage in Form Requests
Conditional Example
Using ChainRule with Arrays and ChainRule Objects
Preventing XSS / Unsafe HTML
You can allow only safe HTML while rejecting scripts and malicious attributes:
Or allow only specific tags:
Helper Method
For convenience, you can use the global chainRule() helper instead of ChainRule::make():
Mass Method
LICENSE
The MIT License (MIT). Please see License File for more information.
All versions of laravel-chain-rule with dependencies
PHP Build Version
Package Version
The package kentjerone/laravel-chain-rule contains the following files
Loading the files please wait ...