mirror of
https://github.com/pelican-dev/panel.git
synced 2025-09-08 09:58:37 +02:00
Add file name Validation
This commit is contained in:
parent
3543b4773a
commit
d9c2e7646a
@ -136,6 +136,7 @@ class ListFiles extends ListRecords
|
||||
->form([
|
||||
TextInput::make('name')
|
||||
->label(trans('server/file.actions.rename.name'))
|
||||
->rules(File::getRulesForField('name'))
|
||||
->default(fn (File $file) => $file->name)
|
||||
->required(),
|
||||
])
|
||||
@ -189,6 +190,7 @@ class ListFiles extends ListRecords
|
||||
->form([
|
||||
TextInput::make('location')
|
||||
->label(trans('server/file.actions.move.new_location'))
|
||||
->rules(File::getRulesForField('name'))
|
||||
->hint(trans('server/file.actions.move.new_location_hint'))
|
||||
->required()
|
||||
->live(),
|
||||
@ -349,6 +351,7 @@ class ListFiles extends ListRecords
|
||||
->form([
|
||||
TextInput::make('location')
|
||||
->label(trans('server/file.actions.move.directory'))
|
||||
->rules(File::getRulesForField('name'))
|
||||
->hint(trans('server/file.actions.move.directory_hint'))
|
||||
->required()
|
||||
->live(),
|
||||
@ -451,6 +454,7 @@ class ListFiles extends ListRecords
|
||||
->form([
|
||||
TextInput::make('name')
|
||||
->label(trans('server/file.actions.new_file.file_name'))
|
||||
->rules(File::getRulesForField('name'))
|
||||
->required(),
|
||||
Select::make('lang')
|
||||
->label(trans('server/file.actions.new_file.syntax'))
|
||||
@ -492,6 +496,7 @@ class ListFiles extends ListRecords
|
||||
->form([
|
||||
TextInput::make('name')
|
||||
->label(trans('server/file.actions.new_folder.folder_name'))
|
||||
->rules(File::getRulesForField('name'))
|
||||
->required(),
|
||||
]),
|
||||
HeaderAction::make('upload')
|
||||
@ -556,9 +561,9 @@ class ListFiles extends ListRecords
|
||||
->form([
|
||||
TextInput::make('searchTerm')
|
||||
->label(trans('server/file.actions.global_search.search_term'))
|
||||
->placeholder(trans('server/file.actions.global_search.search_term_placeholder'))
|
||||
->rules(array_merge(File::getRulesForField('name'), ['regex:/^[^*]*\*?[^*]*$/']))
|
||||
->required()
|
||||
->regex('/^[^*]*\*?[^*]*$/')
|
||||
->placeholder(trans('server/file.actions.global_search.search_term_placeholder'))
|
||||
->minValue(3),
|
||||
])
|
||||
->action(fn ($data) => redirect(SearchFiles::getUrl([
|
||||
|
@ -2,8 +2,10 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Contracts\Validatable;
|
||||
use App\Livewire\AlertBanner;
|
||||
use App\Repositories\Daemon\DaemonFileRepository;
|
||||
use App\Traits\HasValidation;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@ -26,10 +28,16 @@ use Sushi\Sushi;
|
||||
* @property bool $is_symlink
|
||||
* @property string $mime_type
|
||||
*/
|
||||
class File extends Model
|
||||
class File extends Model implements Validatable
|
||||
{
|
||||
use HasValidation;
|
||||
use Sushi;
|
||||
|
||||
/** @var array<array-key, string[]> */
|
||||
public static array $validationRules = [
|
||||
'name' => ['required', 'string', 'not_regex:/[{}#]/'],
|
||||
];
|
||||
|
||||
protected int $sushiInsertChunkSize = 100;
|
||||
|
||||
public const ARCHIVE_MIMES = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user