Looking to hire Laravel developers? Try LaraJobs

laravel-validate-xss maintained by nayikidev

Description
Laravel validation rule to prevent JavaScript or dangerous HTML tags.
Author
Last update
2025/10/30 04:46 (dev-main)
License
Downloads
6

Comments
comments powered by Disqus

Laravel Validate XSS

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']