Skip to content

Commit f61c8ca

Browse files
authored
Merge pull request #281 from objectstack-ai/copilot/debug-issues-in-action-run
2 parents 4dcbd1d + 6f1c06d commit f61c8ca

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
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', () => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export class ValidationEngine {
171171

172172
case 'phone':
173173
if (typeof value === 'string') {
174-
const phoneRegex = /^[\d\s\-\+\(\)]+$/;
174+
const phoneRegex = /^[\d\s\-+()]+$/;
175175
if (!phoneRegex.test(value)) {
176176
return message || 'Invalid phone number';
177177
}

0 commit comments

Comments
 (0)