An open API service indexing awesome lists of open source software.

https://github.com/sandshellcreations/validationexampleswift

This project contains single generic validations file that can be used for validations on login, signup process or form validations. only one function can work for all view controller validations e.g. there is only one function that is used for login View Controller, signup ViewController and editProfile ViewController also. i've handled the validation cases for email, phone number, name etc. you can add your other RegExes in this file for other validations.
https://github.com/sandshellcreations/validationexampleswift

ios iosdevelopment kissmycode sandshellcreations swift3 tuples validationexampleswift validations validator xcode

Last synced: about 1 month ago
JSON representation

This project contains single generic validations file that can be used for validations on login, signup process or form validations. only one function can work for all view controller validations e.g. there is only one function that is used for login View Controller, signup ViewController and editProfile ViewController also. i've handled the validation cases for email, phone number, name etc. you can add your other RegExes in this file for other validations.

Awesome Lists containing this project

README

        

ValidationExampleSwift
Validation code using tuples and variadic parameters...

Variadic parameter example:-
--------------------------------------------------------------------
func arithmeticMean(_ numbers: Double...) -> Double {
var total: Double = 0
for number in numbers {
total += number
}
return total / Double(numbers.count)
}
arithmeticMean(1, 2, 3, 4, 5)
// returns 3.0, which is the arithmetic mean of these five numbers
arithmeticMean(3, 8.25, 18.75)
// returns 10.0, which is the arithmetic mean of these three numbers
Tuple usage tutorial link: https://medium.com/swift-programming/swift-tuple-328aecff50e7
----------------------------------------------------------------------
Usage Example of validation with three values
----------------------------------------------------------------------
let response = Validation.shared.validate(values: (ValidationType.email, "[email protected]"), (ValidationType.phoneNo, "56545654654665"), (ValidationType.stringWithFirstLetterCaps, "tyh56gf"))
switch response {
case .success:
break
case .failure(_, let message):
print(message.localized())
}
only with two value validations
----------------------------------------------------------------------
let response = Validation.shared.validate(values: (ValidationType.email, "[email protected]"), (ValidationType.stringWithFirstLetterCaps, "tyh56gf"))
switch response {
case .success:
break
case .failure(_, let message):
print(message.localized())
}