|
1 | 1 | {
|
2 |
| - "number": { |
3 |
| - "description": "Cleanup user-entered phone numbers", |
4 |
| - "cases": [ |
5 |
| - { |
6 |
| - "description": "cleans the number", |
7 |
| - "phrase": "(123) 456-7890", |
8 |
| - "expected": "1234567890" |
9 |
| - }, |
10 |
| - { |
11 |
| - "description": "cleans numbers with dots", |
12 |
| - "phrase": "123.456.7890", |
13 |
| - "expected": "1234567890" |
14 |
| - }, |
15 |
| - { |
16 |
| - "description": "cleans numbers with multiple spaces", |
17 |
| - "phrase": "123 456 7890 ", |
18 |
| - "expected": "1234567890" |
19 |
| - }, |
20 |
| - { |
21 |
| - "description": "invalid when 9 digits", |
22 |
| - "phrase": "123456789", |
23 |
| - "expected": null |
24 |
| - }, |
25 |
| - { |
26 |
| - "description": "invalid when 11 digits", |
27 |
| - "phrase": "21234567890", |
28 |
| - "expected": null |
29 |
| - }, |
30 |
| - { |
31 |
| - "description": "valid when 11 digits and starting with 1", |
32 |
| - "phrase": "11234567890", |
33 |
| - "expected": "1234567890" |
34 |
| - }, |
35 |
| - { |
36 |
| - "description": "invalid when 12 digits", |
37 |
| - "phrase": "321234567890", |
38 |
| - "expected": null |
39 |
| - }, |
40 |
| - { |
41 |
| - "description": "invalid with letters", |
42 |
| - "phrase": "123-abc-7890", |
43 |
| - "expected": null |
44 |
| - }, |
45 |
| - { |
46 |
| - "description": "invalid with punctuations", |
47 |
| - "phrase": "123-@:!-7890", |
48 |
| - "expected": null |
49 |
| - }, |
50 |
| - { |
51 |
| - "description": "invalid with right number of digits but letters mixed in", |
52 |
| - "phrase": "1a2b3c4d5e6f7g8h9i0j", |
53 |
| - "expected": null |
54 |
| - } |
55 |
| - ] |
56 |
| - } |
| 2 | + "exercise": "phone-number", |
| 3 | + "version": "1.0.0", |
| 4 | + "cases": [ |
| 5 | + { |
| 6 | + "description": "Cleanup user-entered phone numbers", |
| 7 | + "comments": [ |
| 8 | + " Returns the cleaned phone number if given number is valid, " |
| 9 | + , " else returns nil. Note that number is not formatted, " |
| 10 | + , " just a 10-digit number is returned. " |
| 11 | + ], |
| 12 | + "cases": [ |
| 13 | + { |
| 14 | + "description": "cleans the number", |
| 15 | + "property": "clean", |
| 16 | + "phrase": "(123) 456-7890", |
| 17 | + "expected": "1234567890" |
| 18 | + }, |
| 19 | + { |
| 20 | + "description": "cleans numbers with dots", |
| 21 | + "property": "clean", |
| 22 | + "phrase": "123.456.7890", |
| 23 | + "expected": "1234567890" |
| 24 | + }, |
| 25 | + { |
| 26 | + "description": "cleans numbers with multiple spaces", |
| 27 | + "property": "clean", |
| 28 | + "phrase": "123 456 7890 ", |
| 29 | + "expected": "1234567890" |
| 30 | + }, |
| 31 | + { |
| 32 | + "description": "invalid when 9 digits", |
| 33 | + "property": "clean", |
| 34 | + "phrase": "123456789", |
| 35 | + "expected": null |
| 36 | + }, |
| 37 | + { |
| 38 | + "description": "invalid when 11 digits", |
| 39 | + "property": "clean", |
| 40 | + "phrase": "21234567890", |
| 41 | + "expected": null |
| 42 | + }, |
| 43 | + { |
| 44 | + "description": "valid when 11 digits and starting with 1", |
| 45 | + "property": "clean", |
| 46 | + "phrase": "11234567890", |
| 47 | + "expected": "1234567890" |
| 48 | + }, |
| 49 | + { |
| 50 | + "description": "invalid when 12 digits", |
| 51 | + "property": "clean", |
| 52 | + "phrase": "321234567890", |
| 53 | + "expected": null |
| 54 | + }, |
| 55 | + { |
| 56 | + "description": "invalid with letters", |
| 57 | + "property": "clean", |
| 58 | + "phrase": "123-abc-7890", |
| 59 | + "expected": null |
| 60 | + }, |
| 61 | + { |
| 62 | + "description": "invalid with punctuations", |
| 63 | + "property": "clean", |
| 64 | + "phrase": "123-@:!-7890", |
| 65 | + "expected": null |
| 66 | + }, |
| 67 | + { |
| 68 | + "description": "invalid with right number of digits but letters mixed in", |
| 69 | + "property": "clean", |
| 70 | + "phrase": "1a2b3c4d5e6f7g8h9i0j", |
| 71 | + "expected": null |
| 72 | + } |
| 73 | + ] |
| 74 | + } |
| 75 | + ] |
57 | 76 | }
|
0 commit comments