Skip to content

Move IsDigitsOnly into its own file, trim comment - #54

Merged
buzz-code merged 1 commit into
mainfrom
claude/is-digits-only-own-file
Sep 9, 2026
Merged

buzz-code merged 1 commit into
mainfrom
claude/is-digits-only-own-file

Conversation

@buzz-code

Copy link
Copy Markdown
Owner

Follow-up to #53 per review feedback.

  • IsDigitsOnly moved into its own is-digits-only.ts, following the IsUniqueCombination / IsUniqueDateRange / MaxCountByUserLimit pattern (raw decorator via registerDecorator, wrapped in class-validator-he.ts for the Hebrew message).
  • Dropped the verbose block comment.
  • Removed the IsDigitsOnly block from class-validator-he.spec.ts (IsUniqueCombination/IsUniqueDateRange aren't tested there either) in favor of a dedicated is-digits-only.spec.ts.

No behavior change. Verified via the react-admin-nestjs consumer checkout: 118/1034 tests pass, tsc --noEmit clean, and a manual check confirms the wrapped decorator still produces the translated Hebrew message end-to-end.

The react-admin-nestjs submodule pointer is not bumped yet — that'll happen in a later change.

🤖 Generated with Claude Code

https://claude.ai/code/session_016mY7oyUH46UtvEKekiF7fT


Generated by Claude Code

Follows the IsUniqueCombination / IsUniqueDateRange / MaxCountByUserLimit
pattern: the raw decorator lives in its own file using registerDecorator,
class-validator-he.ts just wraps it with the Hebrew message. Dropped the
verbose block comment and the redundant IsDigitsOnly tests in
class-validator-he.spec.ts (IsUniqueCombination/IsUniqueDateRange aren't
tested there either) in favor of a dedicated is-digits-only.spec.ts.

No behavior change from PR #53.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016mY7oyUH46UtvEKekiF7fT
Copilot AI lite review requested due to automatic review settings September 9, 2026 12:36
@buzz-code
buzz-code merged commit 17436d7 into main Sep 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The constraint name change can alter ValidationError.constraints keys for consumers, and the wrapper export loses smoke-test coverage in the existing class-validator-he test suite.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Refactors the IsDigitsOnly validator to match the repo’s “raw decorator in its own file + Hebrew wrapper in class-validator-he.ts” pattern, and moves its tests into a dedicated spec file while trimming commentary.

Changes:

  • Added utils/validation/is-digits-only.ts implementing the raw IsDigitsOnly decorator via registerDecorator.
  • Updated utils/validation/class-validator-he.ts to wrap the new raw decorator instead of defining the validator inline.
  • Moved unit tests from class-validator-he.spec.ts into a dedicated is-digits-only.spec.ts.
File summaries
File Description
utils/validation/is-digits-only.ts New standalone raw IsDigitsOnly decorator implementation.
utils/validation/class-validator-he.ts Hebrew wrapper now delegates to ./is-digits-only.
utils/validation/tests/is-digits-only.spec.ts New dedicated test suite for the raw decorator.
utils/validation/tests/class-validator-he.spec.ts Removes IsDigitsOnly tests from the wrapper suite.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

export function IsDigitsOnly(maxLength?: number, validationOptions?: ValidationOptions) {
return function (object: Object, propertyName: string) {
registerDecorator({
name: 'IsDigitsOnly',
Comment on lines 145 to 149
describe('getTranslatedConstraint', () => {
it('should return the correct translated constraint', () => {
expect(getTranslatedConstraint('StudentByYear')).toBe('שיוך תלמידות');
});
});
Comment on lines +5 to +15
it('should not return an error for undefined, null or an empty string', async () => {
class Test {
@IsDigitsOnly() key: string;
}

const test = new Test();
expect(await validate(test)).toEqual([]);

test.key = '';
expect(await validate(test)).toEqual([]);
});
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