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

v1.0.1 2025-10-30 02:27 UTC

This package is auto-updated.

Last update: 2025-11-30 04:05:05 UTC


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