Skip to content

Instantly share code, notes, and snippets.

View didats's full-sized avatar

Didats Triadi didats

View GitHub Profile
@didats
didats / civil_id_objectivc.m
Last active December 4, 2018 15:57
Civil ID Validation for Kuwait Citizen in Objective C
-(BOOL) validateCivilID:(NSString *)civilID {
bool valid = false;
NSString *regex = @"[0-9]{12}";
NSPredicate *test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
if ([test evaluateWithObject:civilID]) {
double test = 11 - (([[civilID substringWithRange:NSMakeRange(0, 1)] integerValue] * 2) +
([[civilID substringWithRange:NSMakeRange(1, 1)] integerValue] * 1) +