79680135

Date: 2025-06-26 08:22:29
Score: 0.5
Natty:
Report link

@Marleen is correct. You have to many parameters in your noSpecialChars function. I have a similar function in my CI4 app that looks like this:

public function alpha_numeric_punct_german(string $str, ?string &$error = null)
{
    // M = Math_Symbol, P = Punctuation, L = Latin
    if ((bool) preg_match('/^[^\p{M}\p{P}\p{L}0-9 ~!#$€%\&\*\-\–_+=|:.,„“"`´\']+$/ium', $str)) {
        $error = 'Contains illegal characters';

        return false;
    }

    return true;
}

The $errorargument is optional. You only have to pass string $fields and array $data if you want to pass additional data to your validation rule like for example in in_list[2,5] or valid_date[d.m.Y].

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Marleen
  • Low reputation (0.5):
Posted by: Simon Weber