class StoreResumePersonal extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = [
'user.firstname' => ['required', 'string', 'max:255'],
'user.lastname' => ['required', 'string', 'max:255'],
'user.email' => ['required', 'email', 'unique:users,email,'.$id],
'personal.additional_emails.*' => ['nullable', 'email', 'max:50'],
'personal.additional_phones.*' => ['nullable', 'regex:/^\+?\d+$/', 'min:7', 'max:15'],
'personal.nationality_code' => ['required', 'string', 'size:2'],
'personal.marital' => ['required', 'string', 'max:15'],
'personal.new_ic' => ['required', 'string', 'size:14'],
'personal.passport' => ['nullable', 'string'],
'personal.hand_tel' => ['required', 'regex:/^\+?\d+$/', 'min:7', 'max:15'], // allow + symbol at front
'personal.dob' => ['required', 'date'],
'personal.gender' => ['required'],
'personal.race' => ['required'],
'interviewerNotes.who_rec_text' => ['required_if:interviewerNotes.who_rec,others']
];
return $rules;
}
public function messages(){
$messages = [
'personal.hand_tel.regex' => 'The :attribute format is invalid (format: +601212345678).',
'personal.additional_phones.*.regex' => 'The :attribute format is invalid (format: +601212345678).',
'interviewerNotes.who_rec_text.required_if' => 'Please provide the anwswer on how did you hear about us.',
];
return $messages;
}
/**
* Get custom attributes for validator errors.
*
* @return array
*/
public function attributes()
{
$attributes = [
'user.firstname' => 'firstname',
'user.lastname' => 'lastname',
'user.email' => 'email',
'personal.additional_emails.*' => 'email',
'personal.additional_phones.*' => 'phone',
'personal.nationality_code' => 'nationality',
'personal.marital' => 'marital',
'personal.new_ic' => 'NRIC',
'personal.passport' => 'passport',
'personal.hand_tel' => 'phone',
'personal.dob' => 'date of birth',
'personal.gender' => 'gender',
'personal.race' => 'race',
];
return $attributes;
}
}