nayikidev / laravel-validate-xss
Laravel validation rule to prevent JavaScript or dangerous HTML tags.
Package info
github.com/rifkifathur/laravel-validate-xss
pkg:composer/nayikidev/laravel-validate-xss
v1.0.1
2025-10-30 02:27 UTC
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']