Repository navigation
Move IsDigitsOnly into its own file, trim comment - #54
Merged
Merged
Conversation
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
There was a problem hiding this comment.
🟡 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.tsimplementing the rawIsDigitsOnlydecorator viaregisterDecorator. - Updated
utils/validation/class-validator-he.tsto wrap the new raw decorator instead of defining the validator inline. - Moved unit tests from
class-validator-he.spec.tsinto a dedicatedis-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([]); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #53 per review feedback.
IsDigitsOnlymoved into its ownis-digits-only.ts, following theIsUniqueCombination/IsUniqueDateRange/MaxCountByUserLimitpattern (raw decorator viaregisterDecorator, wrapped inclass-validator-he.tsfor the Hebrew message).IsDigitsOnlyblock fromclass-validator-he.spec.ts(IsUniqueCombination/IsUniqueDateRangearen't tested there either) in favor of a dedicatedis-digits-only.spec.ts.No behavior change. Verified via the react-admin-nestjs consumer checkout: 118/1034 tests pass,
tsc --noEmitclean, 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