Validation.swift 566 B

1234567891011121314151617181920212223242526
  1. //
  2. // Validation.swift
  3. // Learn Genie
  4. //
  5. // Created by Suraj Kumar Mandal on 18/09/21.
  6. //
  7. import Foundation
  8. class Validation {
  9. func isValidEmail(_ email: String) -> Bool {
  10. let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
  11. let emailPred = NSPredicate(format:"SELF MATCHES %@", emailRegEx)
  12. return emailPred.evaluate(with: email)
  13. }
  14. func isValidPhoneNo(_ phone: String) -> Bool {
  15. if phone.count != 10 {
  16. return false
  17. } else {
  18. return true
  19. }
  20. }
  21. }