use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class CreateRequest extends FormRequest
{
public function rules(): array
{
return [
'domain' => [
'required',
'regex:/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i', // no schema
Rule::unique('domains')
->whereNull('deleted_at'),
Rule::notIn(config('domains.available'))
],
'not_found_url' => ['nullable', 'max:255', 'url'],
'expired_url' => ['nullable', 'max:255', 'url'],
];
}
public function messages()
{
return [
'domain.regex' => 'The domain format is invalid.',
'domain.unique' => 'The domain has already been taken.',
'domain.not_in' => 'The domain is not allowed.',
];
}
}