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.
- Host: GitHub
- URL: https://github.com/sandshellcreations/validationexampleswift
- Owner: SandsHellCreations
- Created: 2017-09-14T07:07:24.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-15T06:19:59.000Z (over 7 years ago)
- Last Synced: 2025-03-26T19:45:35.307Z (about 2 months ago)
- Topics: ios, iosdevelopment, kissmycode, sandshellcreations, swift3, tuples, validationexampleswift, validations, validator, xcode
- Language: Swift
- Homepage:
- Size: 17.6 KB
- Stars: 14
- Watchers: 2
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
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())
}