Files
coolify/app/Traits/HasSafeStringAttribute.php
Andras Bacsai 38c0641734 feat(validation): centralize validation patterns for names and descriptions
- Introduced `ValidationPatterns` class to standardize validation rules and messages for name and description fields across the application.
- Updated various components and models to utilize the new validation patterns, ensuring consistent sanitization and validation logic.
- Replaced the `HasSafeNameAttribute` trait with `HasSafeStringAttribute` to enhance attribute handling and maintain consistency in name sanitization.
- Enhanced the `CleanupNames` command to align with the new validation rules, allowing for a broader range of valid characters in names.
2025-08-19 12:14:48 +02:00

26 lines
548 B
PHP

<?php
namespace App\Traits;
trait HasSafeStringAttribute
{
/**
* Set the name attribute - strip any HTML tags for safety
*/
public function setNameAttribute($value)
{
$sanitized = strip_tags($value);
$this->attributes['name'] = $this->customizeName($sanitized);
}
protected function customizeName($value)
{
return $value; // Default: no customization
}
public function setDescriptionAttribute($value)
{
$this->attributes['description'] = strip_tags($value);
}
}