File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
packages/core/src/validation/__tests__ Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff 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' , ( ) => {
You can’t perform that action at this time.
0 commit comments