feat(cleanup): add command for sanitizing name fields across models

- Introduced `CleanupNames` command to sanitize name fields by removing invalid characters, ensuring only letters, numbers, spaces, dashes, underscores, and dots are retained.
- Implemented options for dry run, model-specific cleaning, database backup, and forced execution.
- Updated `Init` command to call the new `cleanup:names` command.
- Enhanced project and environment validation to enforce name sanitization rules.
- Added `HasSafeNameAttribute` trait to relevant models for consistent name handling.
This commit is contained in:
Andras Bacsai
2025-08-19 11:04:23 +02:00
parent 6727fd958f
commit e958b3761d
28 changed files with 364 additions and 26 deletions

View File

@@ -9,12 +9,18 @@ use Visus\Cuid2\Cuid2;
class AddEmpty extends Component
{
#[Validate(['required', 'string', 'min:3'])]
#[Validate(['required', 'string', 'min:3', 'max:255', 'regex:/^[a-zA-Z0-9\s\-_.]+$/'])]
public string $name;
#[Validate(['nullable', 'string'])]
public string $description = '';
protected $messages = [
'name.regex' => 'The name may only contain letters, numbers, spaces, dashes, underscores, and dots.',
'name.min' => 'The name must be at least 3 characters.',
'name.max' => 'The name may not be greater than 255 characters.',
];
public function submit()
{
try {