-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
bugVerified issues on the current code behavior or pull requests that will fix themVerified issues on the current code behavior or pull requests that will fix them
Description
Describe the bug
When using validation placeholders in a model and validating data, the placeholder is not being replaced with the actual data. The validation therefore returns false.
CodeIgniter 4 version
4.0.2
Expected behavior, and steps to reproduce if appropriate
Using the myth-auth package and the GroupModel. Validation rules are defined in the model as:
protected $validationRules = [
'name' => 'required|max_length[255]|is_unique[auth_groups.name,name,{name}]',
'description' => 'max_length[255]',
];
When trying to update a group in the controller using an already existing name in the database:
$groupModel = new GroupModel();
if (! $this->validate($rules = $groupModel->getValidationRules())) {
return redirect()->back()->withInput()->with('errors', $groupModel->errors());
}
The validation returns false. Looking at the DB (MySQL) query ran it can be seen why:
SELECT 1 FROM `auth_groups` WHERE `name` = 'admin' AND `name` != '{name}' LIMIT 1
A manual replacement of {name} with the actual value resolves the issue.
Metadata
Metadata
Assignees
Labels
bugVerified issues on the current code behavior or pull requests that will fix themVerified issues on the current code behavior or pull requests that will fix them