Laravel Validations:
List of types
"first_name" => 'required|alpha:ascii|min:3|max:100',// alpha:ascii (only accepts a-z)
"middle_name" => 'string',
"last_name" => 'required|string',
"email" => 'required|email|unique:users,email',
"password" => 'required|string|confirmed',
"sex" => 'required|string',
"phone_no" => 'required|string',
"account_type" => 'required|string',
"dob" => 'required|date_format:d-m-Y', // date with format
"nationality" => 'required|string',
"company" => 'required|string',
"company_sector" => 'required|string',
"company_address" => 'required|string'
"bank_account_no" => 'required|min_digits:3|max_digits:5',
"role" => 'required|in:admin,editor,viewer',
public function rules(): array
{
return [
'status' => 'required|in:Publish,Private,Draft,Delete,Pending',
];
}
/* Example of showing error messages */
public function messages(): array
{
return [
'status.in' => 'The selected status is invalid. Allowed values are: Publish, Private, Draft, Delete, or Pending.',
];
}
###
Comments
Post a Comment
Thank you :)