Validation Issue - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19) +--- Thread: Validation Issue (/showthread.php?tid=91483) |
Validation Issue - munggaran - 08-16-2024 Just got my project updated to CI 4.5.4, most of the issue solved by following guide and internet forum, but this I found by myself and currently tweak bit my code for compatibility with latest update: Issue: Validation field now will not accept number, even has been passed as string like (string)$myvariable , this will still raise an error. Step to produce: Just make database field name using only number e.g. field "111" or "222", make validation such as required/string/int/etc then it will raise an error when running validation. Hope in the future this could be fixed because I use number as field number, adding prefix into code is somewhat challenging risk of bug. RE: Validation Issue - kenjis - 08-16-2024 Thank you for reporting! We don't know this issue. Can you show the exact whole error message? And what version of CI4 did work? RE: Validation Issue - InsiteFX - 08-17-2024 MySQL states that all columns with all numbers must be enclosed in double quotes. RE: Validation Issue - munggaran - 08-22-2024 (08-16-2024, 07:46 PM)kenjis Wrote: Thank you for reporting! Code: ========================= This works in CI 4.0, number as field names still accepted. Other bugs that I found is when I put only "trim" as validation then this will raise same error, I just want to make sure that user put something instead string with spaces, but this can be escalated by adding regex into validation for now. I read from internet trim in 4.0 was converted into boolean while 4.5.4 just null, this probably leads into validation error. RE: Validation Issue - kenjis - 08-22-2024 Thank you. I got your issue. I sent a PR to fix the bug: https://github.com/codeigniter4/CodeIgniter4/pull/9142 RE: Validation Issue - kenjis - 08-22-2024 (08-22-2024, 12:16 PM)munggaran Wrote: Other bugs that I found is when I put only "trim" as validation then this will raise same error, I just want to make sure that user put something instead string with spaces, but this can be escalated by adding regex into validation for now. I read from internet trim in 4.0 was converted into boolean while 4.5.4 just null, this probably leads into validation error. The trim() function accept a string as the first parameter. See https://www.php.net/manual/en/function.trim.php#refsect1-function.trim-description So if you pass other than a string value, now the error occurs. Type checking in PHP is becoming stricter, so type checking in CI4 is also becoming stricter. To avoid errors, please change so that only strings are passed. Also, because CI4 does not change the data to be validated, specifying trim in the validation rules is meaningless even in 4.0. RE: Validation Issue - nahaK - 12-14-2024 I’ve faced similar issues with field names as numbers. The stricter type-checking in CI 4.5.4 can be tricky. Looking forward to the fix in the PR. |