Files
exchange-2.0/app/Http/Requests/CreateAffiliateRequest.php
T
Edmond Lang 30ed77f304 Merge branch 'affiliate-program' of https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0 into vapor/production
# Conflicts:
#	resources/assets/vue/components/accounts/forms/RegistrationFormComponent.vue
#	routes/api.php
2026-01-26 00:13:10 +08:00

59 lines
1.5 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class CreateAffiliateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// Authorization will be handled by middleware and policy
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'code' => [
'nullable',
'string',
'min:3',
'max:255',
'regex:/^[a-zA-Z0-9_-]+$/',
],
'campaign_name' => 'required|string|max:255',
'campaign_description' => 'nullable|string|max:65535',
'is_active' => 'nullable|boolean',
];
}
/**
* Get custom error messages for validation rules.
*
* @return array
*/
public function messages()
{
return [
'code.regex' => 'The affiliate code may only contain letters, numbers, hyphens, and underscores.',
'code.unique' => 'This affiliate code is already in use.',
'code.min' => 'The affiliate code must be at least 3 characters.',
'campaign_name.required' => 'A campaign name is required.',
'campaign_name.max' => 'The campaign name cannot exceed 255 characters.',
];
}
}