clrghouz/app/Http/Requests/DomainRequest.php
Deon George 35d9e5a5d5
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 39s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m41s
Create Docker Image / Final Docker Image Manifest (push) Successful in 12s
Automatically mark idle nodes HOLD/DOWN/DE-LIST. Automatically validate presented addresses.
2024-05-25 22:25:57 +10:00

40 lines
1016 B
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
use Illuminate\Validation\Rule;
use App\Models\{Domain,Echoarea};
class DomainRequest extends FormRequest
{
public function authorize(Domain $o)
{
return Gate::allows('admin',$o);
}
public function rules(Request $request)
{
if (! $request->isMethod('post'))
return [];
$o = $this->route('o');
return [
'name' => 'required|max:8|regex:/^[a-z-_~]{1,8}$/|unique:domains,name,'.($o->exists ? $o->id : 0),
'dnsdomain' => 'nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i|unique:domains,dnsdomain,'.($o->exists ? $o->id : NULL),
'active' => 'required|boolean',
'public' => 'required|boolean',
'accept_app' => 'required|boolean',
'flatten' => 'nullable|boolean',
'nodestatus_id' => [
'nullable',
Rule::exists(Echoarea::class,'id'),
Rule::in($o->echoareas->pluck('id')),
]
];
}
}