Skip to content

Instantly share code, notes, and snippets.

View pbrewczynski's full-sized avatar
💭
Amundsen

Paweł Brewczynski pbrewczynski

💭
Amundsen
  • Poland - Cracow
View GitHub Profile
@kristopherjohnson
kristopherjohnson / firstDifferenceBetweenStrings.swift
Last active July 19, 2024 19:08
Swift code to find differences between strings and display them in a readable way, useful for displaying unit test results
import Foundation
/// Find first differing character between two strings
///
/// :param: s1 First String
/// :param: s2 Second String
///
/// :returns: .DifferenceAtIndex(i) or .NoDifference
public func firstDifferenceBetweenStrings(s1: NSString, s2: NSString) -> FirstDifferenceResult {
var validators = {
password: function(pass) {
return /[0-9]/.test(pass) && pass.length > 10
}
}
var validate = function(el){
return validators[el.getAttribute('data-validator')](el.value)
}