Allow more values for remote field when creating a database; closes #3842

This commit is contained in:
DaneEveritt 2022-05-07 14:17:10 -04:00
parent b07fdc100c
commit c751ce7f44
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
5 changed files with 22 additions and 10 deletions

View file

@ -67,7 +67,7 @@ class Database extends Model
'database' => 'required|string|alpha_dash|between:3,48',
'username' => 'string|alpha_dash|between:3,100',
'max_connections' => 'nullable|integer',
'remote' => 'required|string|regex:/^[0-9%.]{1,15}$/',
'remote' => 'required|string|regex:/^[\w\-\/.%:]+$/',
'password' => 'string',
];

View file

@ -3,6 +3,7 @@
namespace Pterodactyl\Models;
use Illuminate\Support\Str;
use Illuminate\Support\Arr;
use Illuminate\Validation\Rule;
use Illuminate\Container\Container;
use Illuminate\Contracts\Validation\Factory;
@ -111,6 +112,15 @@ abstract class Model extends IlluminateModel
return $rules;
}
/**
* Returns the rules for a specific field. If the field is not found an empty
* array is returned.
*/
public static function getRulesForField(string $field): array
{
return Arr::get(static::getRules(), $field) ?? [];
}
/**
* Returns the rules associated with the model, specifically for updating the given model
* rather than just creating it.