From cdc1c8e27b40b12dc3407758ffe4670f6b5e4444 Mon Sep 17 00:00:00 2001 From: Tejas Bubane Date: Fri, 10 Mar 2017 14:13:15 +0530 Subject: [PATCH] Make phone-number exercise compatible with the json schema Related to #625. --- exercises/phone-number/canonical-data.json | 129 ++++++++++++--------- 1 file changed, 74 insertions(+), 55 deletions(-) diff --git a/exercises/phone-number/canonical-data.json b/exercises/phone-number/canonical-data.json index 43288fa2ac..9bed77c993 100644 --- a/exercises/phone-number/canonical-data.json +++ b/exercises/phone-number/canonical-data.json @@ -1,57 +1,76 @@ { - "number": { - "description": "Cleanup user-entered phone numbers", - "cases": [ - { - "description": "cleans the number", - "phrase": "(123) 456-7890", - "expected": "1234567890" - }, - { - "description": "cleans numbers with dots", - "phrase": "123.456.7890", - "expected": "1234567890" - }, - { - "description": "cleans numbers with multiple spaces", - "phrase": "123 456 7890 ", - "expected": "1234567890" - }, - { - "description": "invalid when 9 digits", - "phrase": "123456789", - "expected": null - }, - { - "description": "invalid when 11 digits", - "phrase": "21234567890", - "expected": null - }, - { - "description": "valid when 11 digits and starting with 1", - "phrase": "11234567890", - "expected": "1234567890" - }, - { - "description": "invalid when 12 digits", - "phrase": "321234567890", - "expected": null - }, - { - "description": "invalid with letters", - "phrase": "123-abc-7890", - "expected": null - }, - { - "description": "invalid with punctuations", - "phrase": "123-@:!-7890", - "expected": null - }, - { - "description": "invalid with right number of digits but letters mixed in", - "phrase": "1a2b3c4d5e6f7g8h9i0j", - "expected": null - } - ] - } + "exercise": "phone-number", + "version": "1.0.0", + "cases": [ + { + "description": "Cleanup user-entered phone numbers", + "comments": [ + " Returns the cleaned phone number if given number is valid, " + , " else returns nil. Note that number is not formatted, " + , " just a 10-digit number is returned. " + ], + "cases": [ + { + "description": "cleans the number", + "property": "clean", + "phrase": "(123) 456-7890", + "expected": "1234567890" + }, + { + "description": "cleans numbers with dots", + "property": "clean", + "phrase": "123.456.7890", + "expected": "1234567890" + }, + { + "description": "cleans numbers with multiple spaces", + "property": "clean", + "phrase": "123 456 7890 ", + "expected": "1234567890" + }, + { + "description": "invalid when 9 digits", + "property": "clean", + "phrase": "123456789", + "expected": null + }, + { + "description": "invalid when 11 digits", + "property": "clean", + "phrase": "21234567890", + "expected": null + }, + { + "description": "valid when 11 digits and starting with 1", + "property": "clean", + "phrase": "11234567890", + "expected": "1234567890" + }, + { + "description": "invalid when 12 digits", + "property": "clean", + "phrase": "321234567890", + "expected": null + }, + { + "description": "invalid with letters", + "property": "clean", + "phrase": "123-abc-7890", + "expected": null + }, + { + "description": "invalid with punctuations", + "property": "clean", + "phrase": "123-@:!-7890", + "expected": null + }, + { + "description": "invalid with right number of digits but letters mixed in", + "property": "clean", + "phrase": "1a2b3c4d5e6f7g8h9i0j", + "expected": null + } + ] + } + ] }