}> */ public function validateName(string $name, ?int $ignoreId = null): array { if (1 !== preg_match('/^[^%{}]+$/', $name)) { return [[self::ERROR_NAME_CHARACTERS, []]]; } if ($this->taxonomyModel->isNameTaken($name, $ignoreId)) { return [[self::ERROR_NAME_TAKEN, ['%name%' => $name]]]; } return []; } /** * The value list of a `free` parameter (its editable textarea): every line must respect * the technical pattern of the URL values, and duplicates are rejected. * * @param list $parsed * * @return list}> */ public function validateValues(array $parsed): array { $errors = []; $seen = []; foreach ($parsed as [$value]) { if ('' === $value) { continue; } if (isset($seen[$value]) && 1 === $seen[$value]) { $errors[] = [self::ERROR_VALUE_DUPLICATE, ['%value%' => $value]]; } $seen[$value] = ($seen[$value] ?? 0) + 1; if (1 !== preg_match(UtmSettingsValidator::VALUE_PATTERN, $value)) { $errors[] = [self::ERROR_VALUE_INVALID, ['%value%' => $value]]; } } return $errors; } }