Latest 1.0.0
Homepage https://github.com/diamantidis/SwedishSSN
License MIT
Platforms ios 9.3
Authors

CI Status
Version
License
Platform
Swift

A swift library to validate and extract information from a string that represents a Swedish Social Security Number.

Requirements

  • iOS 9.3+
  • Xcode 9.3+
  • Swift 4.0+

Installation

CocoaPods

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

Usage

You can import SwedishSSN into your files

Validate each case with switch


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
}

Validate one specific type with guard case

let ssn = "XXXXXX-XXXX"

guard case SwedishSSN.personnummer(let gender) = SwedishSSN(ssn) else {
    return false
}

Validate one specific type with if case

let ssn = "XXXXXX-XXXX"

if case SwedishSSN.personnummer(let gender) = SwedishSSN(ssn) {
    // Do something if it is a valid personnummer
}

Author

Ioannis Diamantidis, [email protected]

License

SwedishSSN is available under the MIT license. See the LICENSE file for more info.

Acknowledgments

Latest podspec

{
    "name": "SwedishSSN",
    "version": "1.0.0",
    "summary": "A pod to validate and extract information from Swedish Social Security Number",
    "description": "A pod to validate and extract information from Swedish Social Security Number.nValidate if it is a `personnummer`, a `samordningsnummer` or an `organisationsnummer` and extract informationnlike gender and company type accordingly.",
    "homepage": "https://github.com/diamantidis/SwedishSSN",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Ioannis Diamantidis": "[email protected]"
    },
    "source": {
        "git": "https://github.com/diamantidis/SwedishSSN.git",
        "tag": "1.0.0"
    },
    "platforms": {
        "ios": "9.3"
    },
    "swift_version": "4.0",
    "source_files": "SwedishSSN/Classes/**/*"
}

Pin It on Pinterest

Share This