nayikidev / laravel-validate-xss
Laravel validation rule to prevent JavaScript or dangerous HTML tags.
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/nayikidev/laravel-validate-xss
Requires
- php: >=8.1
- illuminate/support: ^10.0|^11.0|^12.0
Requires (Dev)
- orchestra/testbench: ^10.0
- phpunit/phpunit: ^11.0 || ^12.0
README
A lightweight Laravel package that provides a custom validation rule to prevent Cross-Site Scripting (XSS) attacks in user input.
🚀 Features
✅ Detects and blocks:
<script>tags- Inline JavaScript attributes (e.g.,
onclick,onload, etc.) - Dangerous input patterns like
javascript:or<img onerror=...>
✅ Works with Laravel’s built-in Validator and FormRequest
✅ Plug-and-play: no config required
Minimum Requirements
- PHP >= 8.1
- Laravel 10.x
- Composer
🧩 Installation
1️⃣ Add to your Laravel project
composer require nayikidev/laravel-validate-xss
Using the Validation Rule
'field' => ['xss_protection']