This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check Iranian National Code Validity - Clojure, C#, Ruby, JavaScript, Python, Scala, Java 8, PHP, C, Go, Swift3.0 | |
// بررسی صحت کد ملی ایران - کلوژر، سیشارپ، روبی، جاوااسکریپت، پایتون، اسکالا، جاوا ۸، پیاچپی، سی، گو | |
// در نسخههای قبل یکسان بودن اعداد نا معتبر تشخیص داده میشد ولی | |
// اعداد یکسان نامعتبر نیست http://www.fardanews.com/fa/news/127747 | |
/** | |
* @author Ebrahim Byagowi (2013-) | |
* @lincense: Public Domain | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct UserProfile { | |
let name: String | |
let lastName: String | |
let cellNumber: String | |
let email: String? | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typealias Email = String | |
typealias CellNumber = String | |
struct UserProfile { | |
let name: String | |
let lastName: String | |
let cellNumber: CellNumber | |
let email: Email? | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Email { | |
let address: String | |
/** Or instead of saving the address, extract it on initliazation to localPort@domain | |
* and generate address everytime someone tries to access it? | |
* the thing is, we can do that in future, without changing the public API. | |
*/ | |
// let domain: String | |
// let localPart: String | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct UserProfile { | |
let name: String | |
let lastName: String | |
let cellNumber: String | |
let email: String? | |
} | |
extension UserProfile { | |
var fullName: String { | |
return name + " " + cellNumber |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct User { | |
let id: String | |
let cellNumber: String | |
let isRegistered: Bool | |
let profile: UserProfile? | |
} | |
struct UserProfile { | |
let name: String | |
let lastName: String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typealias UserId = String | |
struct User { | |
let id: UserId | |
let cellNumber: CellNumber | |
let isRegistered: Bool | |
let profile: UserProfile? | |
} | |
struct UserProfile { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct User { | |
typealias Id = String | |
let id: Id | |
let cellNumber: CellNumber | |
let isRegistered: Bool | |
let profile: Profile? | |
struct Profile { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct User { | |
typealias Id = String | |
let id: Id | |
let cellNumber: CellNumber | |
let status: Status | |
enum Status { | |
case notRegistered |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// not registered user | |
"user": { | |
"id": "a_unique_id", | |
"cell_number": "+989354358291", | |
"is_registered": false | |
} | |
// registered user | |
"user": { | |
"id": "a_unique_id", | |
"cell_number": "+989354358291", |
OlderNewer