1- # SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
1+ # SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
22# SPDX-License-Identifier: Apache-2.0
33import re
44from pathlib import Path
1010from idf_component_tools .archive_tools import ArchiveError , get_format_from_path
1111from idf_component_tools .constants import COMPILED_COMMIT_ID_RE , COMPILED_GIT_URL_RE
1212from idf_component_tools .manifest import WEB_DEPENDENCY_REGEX
13- from idf_component_tools .manifest .constants import SLUG_REGEX
13+ from idf_component_tools .manifest .constants import MAX_NAME_LENGTH , SLUG_REGEX
1414from idf_component_tools .semver import Version
1515from idf_component_tools .semver .base import SimpleSpec
1616
@@ -19,10 +19,11 @@ def validate_name(ctx, param, value): # noqa: ARG001
1919 if value is not None :
2020 name = value .lower ()
2121
22- if not re .match (SLUG_REGEX , name ):
22+ if len ( name ) > MAX_NAME_LENGTH or not re .match (SLUG_REGEX , name ):
2323 raise click .BadParameter (
24- f'"{ name } " should consist of 2 or more letters, numbers, "-" or "_". '
25- 'It cannot start or end with "_" or "-", or have sequences of these characters.'
24+ f'"{ name } " must be between 2 and { MAX_NAME_LENGTH } characters long, '
25+ 'consist of letters, numbers, "-" or "_", and cannot start or end with "_" or "-", '
26+ 'nor contain consecutive special characters.'
2627 )
2728 return name
2829
0 commit comments