FIX_Validation

This commit is contained in:
sanjeev.p 2026-02-13 09:05:41 +05:30
parent d10d849389
commit 2b67f5b77f
4 changed files with 88 additions and 39 deletions

View File

@ -1717,14 +1717,14 @@ class ClientController extends AdminController
]
],
];
if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([
'status' => false,
'message' => 'Input validation failed',
'code' => 400,
'errors' => $this->validator->getErrors()
]);
}
// if (!$this->validate($rules)) {
// return $this->response->setStatusCode(400)->setJSON([
// 'status' => false,
// 'message' => 'Input validation failed',
// 'code' => 400,
// 'errors' => $this->validator->getErrors()
// ]);
// }
$id = $this->request->getPost('PrimaryKey');
$data['client_id'] = $this->request->getPost('client_id');

View File

@ -254,7 +254,7 @@ class MasterController extends AdminController
$this->myLogger->logme('error','Insurer Onboarding function called');
$headerData['tab_name'] = 'Insurer Masters';
$headerData['page_name'] = 'Insurers';
$types = array(
(object) array('id' => 'pvt', 'name' => 'PVT'),
(object) array('id' => 'psu', 'name' => 'PSU')
@ -284,29 +284,78 @@ class MasterController extends AdminController
$this->myLogger->logme('error','Insurer general info function called');
$rules = [
'name' => [
'rules' => 'required',
'errors' => [
'required' => 'Name is required'
]
],
'short_name' => [
'rules' => 'required|min_length[3]|max_length[8]',
'errors' => [
'required' => 'Short name is required',
'min_length' => 'Short name must be at least 3 characters',
'max_length' => 'Short name cannot exceed 8 characters'
]
],
'insurer_logo' => [
'name' => [
'label' => 'Insurer Name',
'rules' => ['required', 'regex_match[/^[a-zA-Z0-9\s\-_]+$/]'],
'errors' => [
'required' => 'Insurer Name is required.',
'regex_match' => 'Insurer Name can only contain letters, numbers, spaces, hyphens, and underscores.',
]
],
'short_name' => [
'label' => 'Insurer Short Name',
'rules' => ['required', 'regex_match[/^[a-zA-Z0-9\-_]+$/]'],
'errors' => [
'required' => 'Short Name is required.',
'regex_match' => 'Short Name can only contain letters, numbers, hyphens, and underscores.',
]
],
'type' => [
'label' => 'Insurer Type',
'rules' => 'permit_empty|in_list[pvt,psu]',
'errors' => [
'in_list' => 'Please select a valid Insurer Type (PVT or PSU).'
]
],
'category' => [
'label' => 'Insurer Category',
'rules' => 'permit_empty|in_list[life,general]',
'errors' => [
'in_list' => 'Please select a valid Category (Life or General).'
]
],
'addition_add_day' => [
'rules' => 'permit_empty' // Checkboxes return null if unchecked
],
'deletion_add_day' => [
'rules' => 'permit_empty'
],
'is_multi_event' => [
'rules' => 'permit_empty'
],
'insurer_logo' => [
'rules' => 'if_exist|is_image[insurer_logo]|max_size[insurer_logo,200]|ext_in[insurer_logo,jpg,jpeg,png]',
'errors' => [
'is_image' => 'The uploaded file must be an image',
'max_size' => 'File size should not exceed 200 KB',
'ext_in' => 'Allowed file types: jpg, jpeg, png',
]
],
];
],
];
// $rules = [
// 'name' => [
// 'rules' => 'required',
// 'errors' => [
// 'required' => 'Name is required'
// ]
// ],
// 'short_name' => [
// 'rules' => 'required|min_length[3]|max_length[8]',
// 'errors' => [
// 'required' => 'Short name is required',
// 'min_length' => 'Short name must be at least 3 characters',
// 'max_length' => 'Short name cannot exceed 8 characters'
// ]
// ],
// 'insurer_logo' => [
// 'rules' => 'if_exist|is_image[insurer_logo]|max_size[insurer_logo,200]|ext_in[insurer_logo,jpg,jpeg,png]',
// 'errors' => [
// 'is_image' => 'The uploaded file must be an image',
// 'max_size' => 'File size should not exceed 200 KB',
// 'ext_in' => 'Allowed file types: jpg, jpeg, png',
// ]
// ],
// ];
if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([

View File

@ -1136,11 +1136,11 @@ class TicketController extends BaseController
$rules = [
// --- EMPLOYEE DETAILS ---
'emp_code' => [
'label' => 'Employee Code',
'label' => 'Employee ID',
'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9_-]+$/]',
'errors' => [
'required' => 'Employee Code is required.',
'regex_match' => 'Employee Code cannot contain spaces or special characters (only letters, numbers, hyphens and underscores. allowed).'
'required' => 'Employee ID is required.',
'regex_match' => 'Employee ID cannot contain spaces or special characters (only letters, numbers, hyphens and underscores. allowed).'
]
],
'emp_name' => [
@ -1332,11 +1332,11 @@ class TicketController extends BaseController
$rules = [
// --- EMPLOYEE DETAILS ---
'emp_code' => [
'label' => 'Employee Code',
'label' => 'Employee ID',
'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9_-]+$/]',
'errors' => [
'required' => 'Employee Code is required.',
'regex_match' => 'Employee Code cannot contain spaces or special characters (only letters, numbers, hyphens and underscores. allowed).',
'required' => 'Employee ID is required.',
'regex_match' => 'Employee ID cannot contain spaces or special characters (only letters, numbers, hyphens and underscores. allowed).',
]
],
'emp_name' => [
@ -1471,11 +1471,11 @@ class TicketController extends BaseController
$rules = [
// --- EMPLOYEE DETAILS ---
'emp_code' => [
'label' => 'Employee Code',
'label' => 'Employee ID',
'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9_-]+$/]',
'errors' => [
'required' => 'Employee Code is required.',
'regex_match' => 'Employee Code cannot contain spaces or special characters (only letters, numbers, hyphens and underscores. allowed).',
'required' => 'Employee ID is required.',
'regex_match' => 'Employee ID cannot contain spaces or special characters (only letters, numbers, hyphens and underscores. allowed).',
]
],
'emp_name' => [
@ -1653,11 +1653,11 @@ class TicketController extends BaseController
$rules = [
// --- EMPLOYEE DETAILS ---
'emp_code' => [
'label' => 'Employee Code',
'label' => 'Employee ID',
'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9_-]+$/]',
'errors' => [
'required' => 'Employee Code is required.',
'regex_match' => 'Employee Code cannot contain spaces or special characters (only letters, numbers, hyphens and underscores. allowed).',
'required' => 'Employee ID is required.',
'regex_match' => 'Employee ID cannot contain spaces or special characters (only letters, numbers, hyphens and underscores. allowed).',
]
],
'emp_name' => [

View File

@ -67,7 +67,7 @@
<div class="form-row">
<div class="form-group col-md-6">
<label for="mobile">CD Account Number<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="cd_ac_no_for_cd_master" name="cd_ac_no" required data-parsley-type="digits">
<input type="text" class="form-control" id="cd_ac_no_for_cd_master" name="cd_ac_no" onkeypress="return onlyNumbers(event)" required data-parsley-type="digits">
</div>
<div class="form-group col-md-6">