CocoaPods trunk is moving to be read-only. Read more on the blog, there are 9 months to go.

Spritz 1.0.1

Spritz 1.0.1

Maintained by TheInkedEngineer.



Spritz 1.0.1

  • By
  • Firas Safa

Spritz logo

Twitter Documentation PodVersion SwiftLang badge Platform

Spritz

Spritz is an italian tax code (codice fiscale) generator and validator on steroids written in Swift.

It offers anything from simple regex validator, to complex analysis using the user's information, taking into account the omocodia phenomenon.

The library is fully tested and documented.

1. Requirements and Compatibility

Swift Spritz iOS
5.1+ 1.0.x 10+

2. Installation

Cocoapods

Add the following line to your Podfile pod 'Spritz' ~> '1.0.0'

3. Documentation

Spritz is fully documented. Checkout the documentation here.

4. Code Example

Generating a Codice Fiscale

struct Person: SpritzInformationProvider {
  var firstName = "First"
  var lastName = "Last"
  var dateOfBirth = Date(timeIntervalSince1970: 602562877)
  var sex = Sex.female
  var placeOfBirth = "Cagliari"
}

let codice = try? Spritz.generateCF(from: Person())

Validating a Codice Fiscale

  struct Person: SpritzInformationProvider {
    var firstName = "First"
    var lastName = "Last"
    var dateOfBirth = Date(timeIntervalSince1970: 602562877)
    var sex = Sex.female
    var placeOfBirth = "Cagliari"
  }
    
  let result = try? Spritz.isValid("LSTFST89B44B354F", for: Person()).get()

Validating a Codice Fiscale with omocodia

  struct Person: SpritzInformationProvider {
    var firstName = "First"
    var lastName = "Last"
    var dateOfBirth = Date(timeIntervalSince1970: 602562877)
    var sex = Sex.female
    var placeOfBirth = "Cagliari"
  }
  // the conversion is done automatically.
  let result = try? Spritz.isValid("LSTFST89B44B35QF", for: Person()).get()

5. Contribution

Working on your first Pull Request? You can learn how from this free series How to Contribute to an Open Source Project on GitHub

Generate the project

To generate this project locally, you need xcodegen. It is a great tool to customize a project and generate it on the go.

You can either install it manually following their steps, or just run my setup.sh script. It automatically installs Homebrew if it is missing, installs xcodegen, removes existing (if present) .xcodeproj, run xcodegen and moves configuratiom files to their appropriate place.