PHP Classes

File: src/DataTypes/TextValidator.php

Recommend this page to a friend!
  Packages of Amirreza Ebrahimi   HeroQR Powerful PHP QR Code Library to generate PNG, SVG, PDF, Logos Ready to Use with Laravel   src/DataTypes/TextValidator.php   Download  
File: src/DataTypes/TextValidator.php
Role: Class source
Content type: text/plain
Description: Class source
Class: HeroQR Powerful PHP QR Code Library to generate PNG, SVG, PDF, Logos Ready to Use with Laravel
Generate QR code images in several formats
Author: By
Last change:
Date: 23 days ago
Size: 544 bytes
 

Contents

Class file image Download
<?php

namespace HeroQR\DataTypes;

use
HeroQR\Contracts\DataTypes\AbstractDataType;

/**
 * Validates plain text to prevent unsafe content.
 *
 * Checks for script tags (XSS) and common SQL injection patterns.
 *
 * Example:
 * Text::validate("Hello world");
 */
class TextValidator extends AbstractDataType
{
    public static function
validate(string $data): bool
   
{
       
$text = trim($data);

        if (
self::hasScriptTag($text) || self::hasSqlInjection($text)) {
            return
false;
        }

        return
true;
    }
}