Skip to content

Commit 6f1c06d

Browse files
Copilothotlong
andcommitted
test: Add phone validation test to verify regex fix
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent ed65a6d commit 6f1c06d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

packages/core/src/validation/__tests__/validation-engine.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,31 @@ describe('ValidationEngine', () => {
4747
const result2 = await engine.validate('valid@example.com', schema);
4848
expect(result2.valid).toBe(true);
4949
});
50+
51+
it('should validate phone format', async () => {
52+
const schema: AdvancedValidationSchema = {
53+
field: 'phone',
54+
rules: [
55+
{
56+
type: 'phone',
57+
},
58+
],
59+
};
60+
61+
// Valid phone numbers with various formats
62+
const validResult1 = await engine.validate('123-456-7890', schema);
63+
expect(validResult1.valid).toBe(true);
64+
65+
const validResult2 = await engine.validate('+1 (234) 567-8900', schema);
66+
expect(validResult2.valid).toBe(true);
67+
68+
const validResult3 = await engine.validate('1234567890', schema);
69+
expect(validResult3.valid).toBe(true);
70+
71+
// Invalid phone number with letters
72+
const invalidResult = await engine.validate('123-abc-7890', schema);
73+
expect(invalidResult.valid).toBe(false);
74+
});
5075
});
5176

5277
describe('Custom Validation', () => {

0 commit comments

Comments
 (0)