Skip to content

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 val…

Notifications You must be signed in to change notification settings

SandsHellCreations/ValidationExampleSwift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Usage Example of validation with three values

let response = Validation.shared.validate(values: (ValidationType.email, "hello@gmail.com"), (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, "hello@gmail.com"), (ValidationType.stringWithFirstLetterCaps, "tyh56gf"))
    switch response {
    case .success:
        break
    case .failure(_, let message):
        print(message.localized())
    }

About

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 val…

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages