A swift library to validate and extract information from a string that represents a Swedish Social Security Number.
- iOS 9.3+
- Xcode 9.3+
- Swift 4.0+
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
To integrate SwedishSSN into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.3'
target 'TargetName' do
pod 'SwedishSSN'
end
Then, run the following command:
$ pod install
You can import SwedishSSN
into your files
let ssn = "XXXXXX-XXXX"
switch SwedishSSN(ssn) {
case .personnummer(let gender):
// Do something if it is a valid personnummer
case .samordningsnummer(let gender):
// Do something if it is a valid samordningsnummer
case .organisationsnummer(let companyType):
// Do something if it is a valid organisationsnummer
case .invalid:
// Do something if it is an invalid ssn
}
let ssn = "XXXXXX-XXXX"
guard case SwedishSSN.personnummer(let gender) = SwedishSSN(ssn) else {
return false
}
let ssn = "XXXXXX-XXXX"
if case SwedishSSN.personnummer(let gender) = SwedishSSN(ssn) {
// Do something if it is a valid personnummer
}
Ioannis Diamantidis, diamantidis@outlook.com
SwedishSSN is available under the MIT license. See the LICENSE file for more info.
- https://fejk.se for the fake data 😜