feat: phone validation#2672
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds E.164 phone validation: a ChangesPhone Validation Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
tests/e2e/orm/validation/custom-validation.test.tsOops! Something went wrong! :( ESLint: 9.29.0 ESLint couldn't find an eslint.config.(js|mjs|cjs) file. From ESLint v9.0.0, the default configuration file is now eslint.config.js. https://eslint.org/docs/latest/use/configure/migration-guide If you still have problems after following the migration guide, please stop by Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/e2e/orm/validation/custom-validation.test.ts (1)
83-85: ⚡ Quick winAdd a positive
isPhoneassertion in this test loop.This block only checks rejection; it doesn’t verify that a valid E.164 string passes custom validation (non-null path).
Proposed test addition
// violates phone await expect(_t({ str6: 'not-a-phone' })).toBeRejectedByValidation(['invalid str6']); + + // satisfies phone + await expect(_t({ str6: '+15555555555' })).toResolveTruthy();🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/e2e/orm/validation/custom-validation.test.ts` around lines 83 - 85, Add a positive assertion that the custom isPhone validation accepts a valid E.164 string: call the helper _t with a valid phone value for the str6 field (e.g. an E.164 formatted number) and assert it does not reject validation; update the test loop in custom-validation.test.ts next to the existing rejection check so it verifies both failure for 'not-a-phone' and success for a valid E.164 input.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/zod/test/factory.test.ts`:
- Around line 264-267: The test "rejects invalid phone number for `@phone` field"
is mutating the wrong key; replace the update of website with phone so the
schema validation actually checks the `@phone` rule (i.e., call
factory.makeModelSchema('User') and safeParse with { ...validUser, phone:
'not-a-phone' } instead of updating website) so that result.success will be
false when phone validation fails.
---
Nitpick comments:
In `@tests/e2e/orm/validation/custom-validation.test.ts`:
- Around line 83-85: Add a positive assertion that the custom isPhone validation
accepts a valid E.164 string: call the helper _t with a valid phone value for
the str6 field (e.g. an E.164 formatted number) and assert it does not reject
validation; update the test loop in custom-validation.test.ts next to the
existing rejection check so it verifies both failure for 'not-a-phone' and
success for a valid E.164 input.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 83dcc673-ae78-4055-a655-7fc0b079f692
📒 Files selected for processing (8)
packages/cli/test/db/pull.test.tspackages/language/res/stdlib.zmodelpackages/zod/src/utils.tspackages/zod/test/factory.test.tspackages/zod/test/schema/schema.tspackages/zod/test/schema/schema.zmodeltests/e2e/orm/validation/custom-validation.test.tstests/e2e/orm/validation/toplevel.test.ts
Adds a
@phoneattribute andisPhonefunction that validates E.164 phone numbers.Closes #1897
Summary by CodeRabbit
New Features
Tests