From 9b2c4273f06467a4817fce44aec516f38960e708 Mon Sep 17 00:00:00 2001 From: Donatas Glodenis Date: Mon, 21 Aug 2023 06:24:11 +0300 Subject: [PATCH] Fix for validation placeholder error #351 (#385) --- src/Users/Config/Users.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Users/Config/Users.php b/src/Users/Config/Users.php index 6c257242..53578c0f 100644 --- a/src/Users/Config/Users.php +++ b/src/Users/Config/Users.php @@ -80,20 +80,25 @@ class Users extends BaseConfig * Validation rules used when saving a user. */ public $validation = [ - 'email' => [ - 'label' => 'Email', - 'rules' => 'required|valid_email|unique_email[{id}]', - 'errors'=> [ + 'id' => [ + // Needed for the id in email test; + // see https://codeigniter4.github.io/userguide/installation/upgrade_435.html + 'rules' => 'permit_empty|is_natural_no_zero', + ], + 'email' => [ + 'label' => 'Email', + 'rules' => 'required|valid_email|unique_email[{id}]', + 'errors' => [ 'unique_email' => 'This email is already in use. Could belong to a current or a deleted user.', ], ], - 'username' => [ + 'username' => [ 'label' => 'Username', 'rules' => 'required|string|is_unique[users.username,id,{id}]', ], 'first_name' => [ 'label' => 'First Name', 'rules' => 'permit_empty|string|min_length[3]', ], - 'last_name' => [ + 'last_name' => [ 'label' => 'Last Name', 'rules' => 'permit_empty|string|min_length[3]', ], ];