Skip to content

feat: add new enums for languages and currencies; enhance regex patte…#14

Merged
bybatkhuu merged 1 commit intomainfrom
dev
Feb 23, 2026
Merged

feat: add new enums for languages and currencies; enhance regex patte…#14
bybatkhuu merged 1 commit intomainfrom
dev

Conversation

@bybatkhuu
Copy link
Owner

This pull request expands the constants module by introducing new enums for environment, language, and currency, as well as adding a comprehensive set of regex patterns for input validation. These changes improve the clarity and maintainability of configuration and validation logic across the codebase.

New enums for configuration and localization:

  • Added EnvEnum to represent various deployment environments such as LOCAL, DEVELOPMENT, TEST, DEMO, DOCS, STAGING, and PRODUCTION.
  • Introduced LanguageEnum and CurrencyEnum to standardize supported languages (en, ko, mn, uz) and currencies (USD, KRW, MNT, UZS).

Regex patterns for input validation:

  • Added multiple regex patterns for alphanumeric validation, including support for Korean and Mongolian characters, and patterns for hostnames, paths, and extended character sets.
  • Introduced regex patterns for HTTP methods, asymmetric algorithms, and JWT algorithms to facilitate validation of API and cryptographic inputs.
  • Updated the __all__ list in src/potato_util/constants/_regex.py to export the new regex constants, ensuring they are available for import throughout the project.

@bybatkhuu bybatkhuu self-assigned this Feb 23, 2026
Copilot AI review requested due to automatic review settings February 23, 2026 08:22
@bybatkhuu bybatkhuu added the enhancement New feature or request label Feb 23, 2026
@bybatkhuu bybatkhuu merged commit 7aff2b8 into main Feb 23, 2026
1 check passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request enhances the constants module by adding new enumerations for environment configuration and localization, along with comprehensive regex patterns for input validation. These additions provide standardized constants for common use cases like environment types, language codes, currency codes, and various validation patterns.

Changes:

  • Added three new enum classes: EnvEnum for deployment environments, LanguageEnum for supported languages, and CurrencyEnum for supported currencies
  • Added multiple alphanumeric regex patterns including variants with Korean and Mongolian character support
  • Added regex patterns for HTTP methods, asymmetric algorithms, and JWT algorithms

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/potato_util/constants/_enum.py Added EnvEnum, LanguageEnum, and CurrencyEnum classes with proper exports in all
src/potato_util/constants/_regex.py Added 12 new alphanumeric validation regex patterns and 3 new algorithm/method validation patterns with proper exports in all

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +11 to +14
ALPHANUM_KR_MN_HYPHEN_REGEX = r"^[0-9a-zA-Z가-힣А-яҮүӨөЁё_\-]+$"
ALPHANUM_KR_MN_HOST_REGEX = r"^[0-9a-zA-Z가-힣А-яҮүӨөЁё_\-.]+$"
ALPHANUM_KR_MN_EXTEND_REGEX = r"^[0-9a-zA-Z가-힣А-яҮүӨөЁё_\-. ]+$"
ALPHANUM_KR_MN_PATH_REGEX = r"^[0-9a-zA-Z가-힣А-яҮүӨөЁё_\-. \\\/]+$"
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the previous patterns, the hyphen character in the character class is unnecessarily escaped with a backslash. Consider changing '-' to '-' for cleaner regex patterns. This applies to all Korean/Mongolian patterns (lines 11-14).

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +48
en = "en"
ko = "ko"
mn = "mn"
uz = "uz"
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LanguageEnum uses lowercase for enum member names (en, ko, mn, uz) which deviates from the typical Python enum naming convention. While lowercase is correct for the ISO 639-1 language code values, the enum member names themselves typically follow uppercase conventions as seen in most other enums in this file (WarnEnum, TSUnitEnum, ConfigFileFormatEnum). Consider using uppercase member names mapped to lowercase values: EN = "en", KO = "ko", MN = "mn", UZ = "uz". Note that HashAlgoEnum uses lowercase member names because that's the standard name for hash algorithms, but language codes are different - the code is lowercase but the constant name can be uppercase.

Suggested change
en = "en"
ko = "ko"
mn = "mn"
uz = "uz"
EN = "en"
KO = "ko"
MN = "mn"
UZ = "uz"

Copilot uses AI. Check for mistakes.
Comment on lines +4 to +7
ALPHANUM_HYPHEN_REGEX = r"^[0-9a-zA-Z_\-]+$"
ALPHANUM_HOST_REGEX = r"^[0-9a-zA-Z_\-.]+$"
ALPHANUM_EXTEND_REGEX = r"^[0-9a-zA-Z_\-. ]+$"
ALPHANUM_PATH_REGEX = r"^[0-9a-zA-Z_\-. \\\/]+$"
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hyphen character in the character class is unnecessarily escaped with a backslash. Within a character class, hyphens only need to be escaped if they could be interpreted as a range operator (i.e., when between two characters). Since the hyphen appears after an underscore and backslash here, it's already unambiguous and the escape is redundant. Consider changing '-' to '-' for cleaner regex patterns. This applies to all similar patterns in this file (lines 4-7, 11-14).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants