Skip to content

Instantly share code, notes, and snippets.

View HudiDev's full-sized avatar

Hudi Ilfeld HudiDev

  • United States, Florida
View GitHub Profile
@HudiDev
HudiDev / IsrealiID.Validator.swift
Created June 6, 2019 07:43
Isreali ID Validator (swift)
import Foundation
func israeliIDValidator(idNum: String) -> Bool {
guard Int(idNum) != nil else { return false }
return ("00000000" + idNum).suffix(9).enumerated().reduce(0) {
let step = Int(String($1.1))! * ($1.0 % 2 + 1)
return $0 + (step > 9 ? step - 9 : step)
} % 10 == 0
}