60 lines
1.9 KiB
PHP
60 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class CreateCustomerRequest extends ApiBaseRequest
|
|
{
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
$userData =[
|
|
"package_id"=>"required|integer",
|
|
"first_name"=>"required|string",
|
|
"last_name"=>"required|string",
|
|
'email' => 'required|email|unique:users,email',
|
|
'password'=>'required|min:8|regex:'.$this->password_validation_rule,
|
|
'birth_date'=>'required|date_format:m/d/Y|before:18 years ago|after:-150 years',
|
|
'full_ssn'=>'required|min:4|max:4',
|
|
// 'full_ssn'=>'required|min:9|max:11',
|
|
'street_no'=>'required|string|max:5|regex:'.$this->street_validation_rule,
|
|
'street_name'=>'required|max:50|regex:'.$this->street_validation_rule,
|
|
'city'=>'required|string|regex:'.$this->script_validation_rule,
|
|
'state'=>'required|string|regex:'.$this->script_validation_rule,
|
|
'zip_code'=>'required|string|min:5|max:5|regex:'.$this->script_validation_rule,
|
|
'ssn'=>'required',
|
|
'amount'=>'required',
|
|
'phone'=>'required|string|regex:'.$this->script_validation_rule,
|
|
'is_free'=>'required',
|
|
|
|
];
|
|
$inputData = request()->all();
|
|
|
|
if(isset($inputData['is_free']) && $inputData['is_free'] != 1){
|
|
$userData['card_number'] ='required';
|
|
$userData['cvv_no']='required';
|
|
$userData['expiry']='required';
|
|
|
|
}
|
|
return $userData;
|
|
}
|
|
|
|
/**
|
|
* @return array|string[]
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'street_name.max' => 'The street name may not be greater than 50 characters.',
|
|
'street_name.regex' => 'The street name may not be special characters.',
|
|
];
|
|
}
|
|
}
|