Skip to content

feat: add isUpperCase validator#193

Open
dami0806 wants to merge 7 commits intodevelopfrom
CARGO-365
Open

feat: add isUpperCase validator#193
dami0806 wants to merge 7 commits intodevelopfrom
CARGO-365

Conversation

@dami0806
Copy link
Contributor

• add test code for @IsUppercase decorator
• add example code for @IsUppercase decorator
• add documentation for @IsUppercase decorator

@auto-assign auto-assign bot requested review from laggu, sezeme and yuchem2 March 11, 2026 19:28
@dami0806 dami0806 self-assigned this Mar 11, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new @IsUppercase validation decorator to the express-cargo library. This feature allows developers to easily enforce that a string property contains only uppercase characters. The change includes the core implementation of the validator, along with corresponding unit tests, example usage in the demo application, and comprehensive updates to both English and internationalized documentation to ensure clear understanding and adoption of the new functionality.

Highlights

  • New Validator: Introduced the @IsUppercase decorator, enabling validation for strings that must contain only uppercase characters.
  • Documentation Updates: Updated the main README.md and internationalized documentation files (Korean, German, French, Russian) to include comprehensive details and usage examples for the new @IsUppercase validator.
  • Example Implementation: Added an example implementation and usage instructions for @IsUppercase within the example application and its README.md to demonstrate its functionality.
  • Unit Tests: Implemented a dedicated test file with comprehensive unit tests for the @IsUppercase decorator, covering various validation scenarios including valid, invalid, and non-string inputs, as well as custom error messages.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • README.ko.md
    • Added documentation for the new @IsUppercase validator.
  • README.md
    • Added documentation for the new @IsUppercase validator.
  • apps/docs/i18n/de/docusaurus-plugin-content-docs/current/decorators/validators.md
    • Added German documentation for the @IsUppercase validator.
  • apps/docs/i18n/fr/docusaurus-plugin-content-docs/current/decorators/validators.md
    • Added French documentation for the @IsUppercase validator.
  • apps/docs/i18n/ko/docusaurus-plugin-content-docs/current/decorators/validators.md
    • Added Korean documentation for the @IsUppercase validator.
  • apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/decorators/validators.md
    • Added Russian documentation for the @IsUppercase validator.
  • apps/example/README.md
    • Added an example of how to use the @IsUppercase validator.
  • apps/example/src/routers/validator.ts
    • Imported the IsUppercase decorator and added a new route for its example usage.
  • packages/express-cargo/src/validator.ts
    • Implemented the IsUppercase decorator logic.
  • packages/express-cargo/tests/validator/isUppercase.test.ts
    • Added a new test file with unit tests for the IsUppercase validator.
Activity
  • No specific activity (comments, reviews, progress) was provided in the context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

새로운 @IsUppercase 유효성 검사기 추가에 대한 PR을 검토했습니다. 전반적으로 구현이 잘 되어 있으며, 관련 문서와 예제 코드, 테스트 코드가 모두 포함되어 있어 기능의 완성도가 높습니다. 테스트 코드의 가독성 및 유지보수성 향상을 위한 제안을 한 가지 남겼으니 확인 부탁드립니다.

import { CargoFieldError, IsUppercase } from '../../src'
import { CargoClassMetadata } from '../../src/metadata'

describe('isUppercase decorator', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

테스트 코드의 가독성과 유지보수성을 높이기 위해, 여러 it 블록에서 반복되는 isUppercaseRule을 가져오는 로직을 describe 블록 상단으로 옮기는 것을 제안합니다. 이렇게 하면 중복 코드를 줄이고 각 테스트의 의도를 더 명확하게 파악할 수 있습니다.

예를 들어, 다음과 같이 리팩토링할 수 있습니다:

describe('isUppercase decorator', () => {
    class Sample {
        @IsUppercase()
        uppercaseValue!: string

        noValidatorValue!: string
    }

    const classMeta = new CargoClassMetadata(Sample.prototype);
    const meta = classMeta.getFieldMetadata('uppercaseValue');
    const isUppercaseRule = meta.getValidators()?.find(v => v.type === 'isUppercase');

    it('should have isUppercase validator', () => {
        expect(isUppercaseRule).toBeDefined();
        expect(isUppercaseRule?.message).toBe('uppercaseValue should be uppercase');
    });

    it('should pass for all-uppercase strings', () => {
        expect(isUppercaseRule?.validate('HELLO')).toBeNull();
        // ...
    });

    // ... other tests using isUppercaseRule
});
References
  1. 코드는 항상 읽기 쉽고 이해하기 쉬워야 합니다. 테스트 코드에서 반복되는 로직을 줄이면 가독성과 유지보수성이 향상됩니다. (link)

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

새로운 @IsUppercase 검증기 추가와 관련 문서 및 예제 업데이트를 확인했습니다. 전반적으로 잘 작성된 코드입니다. 구현의 일관성과 성능을 개선할 수 있는 작은 제안을 하나 남깁니다.

new ValidatorRule(
propertyKey,
'isUppercase',
(value: unknown) => typeof value === 'string' && value === value.toUpperCase(),
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

현재 구현은 value.toUpperCase()를 호출하여 새로운 문자열을 할당합니다. 이 방식은 매우 긴 문자열을 검증할 때 미미한 성능 저하를 유발할 수 있습니다.

Alpha, Alphanumeric와 같은 다른 검증기와의 일관성을 위해, 그리고 잠재적인 성능 향상을 위해 정규식을 사용하는 것을 제안합니다.

Suggested change
(value: unknown) => typeof value === 'string' && value === value.toUpperCase(),
(value: unknown) => typeof value === 'string' && !/[a-z]/.test(value),
References
  1. 유사한 기능을 하는 검증기들은 일관된 방식으로 구현하는 것이 좋습니다. 또한, 불필요한 문자열 할당을 피해 성능을 개선할 수 있습니다.

@dami0806
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

새로운 @IsUppercase 유효성 검사기 추가를 위한 PR입니다. 기능 구현, 테스트, 예제 및 문서가 모두 포함되어 있어 전반적으로 잘 구성되었습니다. 다만, IsUppercase 구현 시 유니코드 및 다국어 문자를 처리하는 데 있어 중요한 개선점이 발견되었습니다. 또한, 관련 테스트 케이스를 보강하여 이러한 엣지 케이스들을 검증하는 것이 좋겠습니다. 자세한 내용은 각 파일에 남긴 코멘트를 참고해 주세요.

new ValidatorRule(
propertyKey,
'isUppercase',
(value: unknown) => typeof value === 'string' && !/[a-z]/.test(value),
Copy link
Contributor

Choose a reason for hiding this comment

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

high

@IsUppercase 유효성 검사기의 현재 구현은 ASCII 소문자(a-z)만 확인하므로, 다른 언어의 소문자나 악센트가 있는 문자를 올바르게 처리하지 못합니다. 예를 들어, 'ü'나 'привет'과 같은 문자열이 유효성 검사를 통과하게 됩니다.

String.prototype.toUpperCase()를 사용하여 모든 유니코드 문자를 올바르게 처리하는 것이 더 안정적인 방법입니다.

Suggested change
(value: unknown) => typeof value === 'string' && !/[a-z]/.test(value),
(value: unknown) => typeof value === 'string' && value.toUpperCase() === value,

import { CargoFieldError, IsUppercase } from '../../src'
import { CargoClassMetadata } from '../../src/metadata'

describe('isUppercase decorator', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

IsUppercase 유효성 검사기의 견고성을 높이기 위해 유니코드 문자에 대한 테스트 케이스를 추가하는 것을 권장합니다. 현재 테스트는 ASCII 문자만 다루고 있어, 다국어 환경에서의 동작을 보장하기 어렵습니다.

아래와 같은 테스트 케이스를 추가하여 악센트가 있는 문자나 다른 언어의 대소문자를 올바르게 처리하는지 확인할 수 있습니다.

it('should handle unicode characters correctly', () => {
    // The following will pass with the suggested implementation change
    expect(isUppercaseRule?.validate('ÄÖÜ')).toBeNull(); // Uppercase with accents
    expect(isUppercaseRule?.validate('ÄöÜ')).toBeInstanceOf(CargoFieldError); // Mixed case with accents
    expect(isUppercaseRule?.validate('ПРИВЕТ')).toBeNull(); // Uppercase Cyrillic
    expect(isUppercaseRule?.validate('Привет')).toBeInstanceOf(CargoFieldError); // Mixed case Cyrillic
    expect(isUppercaseRule?.validate('你好')).toBeNull(); // Non-cased characters should pass
});

Copy link
Member

@yuchem2 yuchem2 left a comment

Choose a reason for hiding this comment

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

영어 문서가 누락된 것 같습니다! 영어 문서 작성해주세요!

@dami0806
Copy link
Contributor Author

dami0806 commented Mar 12, 2026

감사합니다! 영어 문서 작성해서 올렸습니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants