Candidate registration, with validation, using MVVM
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
0
down vote
favorite
1
I am new to MVVM. I Created Model class CandidateRegisterModel
and ViewModel class CandidateRegisterViewModel
class CandidateRegisterModel: NSObject
let viewModel = CandidateRegisterViewModel.self
var candidateName : String
var email : String
var mobileNo: Int
var skill : String
var location : String
var totalExp : Int
var designation : String
var industry : String
var uploadResume : String
init(candidateName: String, email: String, mobileNo: Int, skill: String, location: String, totalExp: Int, designation: String, industry: String , uploadResume: String)
self.candidateName = candidateName;
self.email = email;
self.mobileNo = mobileNo;
self.skill = skill;
self.location = location;
self.totalExp = totalExp;
self.designation = designation;
self.industry = industry;
self.uploadResume = uploadResume;
class CandidateRegisterViewModel
var CandidateRegisterData = CandidateRegisterModel?.self
var candidateName : String = ""
var email : String = ""
var mobileNo: Int? = nil
var skill : String = ""
var location : String = ""
var totalExp : Int? = nil
var designation : String = ""
var industry : String = ""
var uploadResume : String = ""
private var errors: [String] =
private weak var context: UIViewController?
init(controller: UIViewController)
context = controller
init(CandidateRegisterDataa : CandidateRegisterModel)
candidateName = CandidateRegisterDataa.candidateName
email = CandidateRegisterDataa.email
mobileNo = CandidateRegisterDataa.mobileNo
skill = CandidateRegisterDataa.skill
location = CandidateRegisterDataa.location
totalExp = CandidateRegisterDataa.totalExp
designation = CandidateRegisterDataa.designation
industry = CandidateRegisterDataa.industry
uploadResume = CandidateRegisterDataa.uploadResume
func checkCandidateNameErrors(name:String) -> Bool
let RegEx = "\A\w7,18\z"
let validator = NSPredicate(format:"SELF MATCHES %@", RegEx)
let valid = validator.evaluate(with: candidateName)
if !valid
errors.append("Invalid UserName")
return valid
func checkEmailErrors(email: String) -> Bool
let regex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]2,4"
let validator = NSPredicate(format: "SELF MATCHES %@", regex)
let valid = validator.evaluate(with: email);
if !valid
errors.append("Invalid Email")
return valid
func checkPhoneErrors(phoneNumber: String) -> Bool
let PHONE_REGEX = "^09[0-9'@s]9,9$"
let validator = NSPredicate(format: "SELF MATCHES %@", PHONE_REGEX)
let valid = validator.evaluate(with: mobileNo)
if !valid
errors.append("Invalid Password")
return valid
func checkPasswordErrors(password: String) -> Bool
let valid = !password.isEmpty && password.count >= 6
if !valid
errors.append("Invalid Password")
return valid
func cleanErrors()
errors.removeAll()
func showErrors()
let message = errors.joined(separator: ("n"))
let errorAlert = UIAlertController(title: "Erros", message: message, preferredStyle: .alert)
errorAlert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
context?.present(errorAlert, animated: true, completion: nil)
extension CandidateRegisterViewModel
func login_model( candidateName : String, email: String, password: String, mobileNo: String)
validation swift ios mvvm swift3
add a comment |Â
up vote
0
down vote
favorite
1
I am new to MVVM. I Created Model class CandidateRegisterModel
and ViewModel class CandidateRegisterViewModel
class CandidateRegisterModel: NSObject
let viewModel = CandidateRegisterViewModel.self
var candidateName : String
var email : String
var mobileNo: Int
var skill : String
var location : String
var totalExp : Int
var designation : String
var industry : String
var uploadResume : String
init(candidateName: String, email: String, mobileNo: Int, skill: String, location: String, totalExp: Int, designation: String, industry: String , uploadResume: String)
self.candidateName = candidateName;
self.email = email;
self.mobileNo = mobileNo;
self.skill = skill;
self.location = location;
self.totalExp = totalExp;
self.designation = designation;
self.industry = industry;
self.uploadResume = uploadResume;
class CandidateRegisterViewModel
var CandidateRegisterData = CandidateRegisterModel?.self
var candidateName : String = ""
var email : String = ""
var mobileNo: Int? = nil
var skill : String = ""
var location : String = ""
var totalExp : Int? = nil
var designation : String = ""
var industry : String = ""
var uploadResume : String = ""
private var errors: [String] =
private weak var context: UIViewController?
init(controller: UIViewController)
context = controller
init(CandidateRegisterDataa : CandidateRegisterModel)
candidateName = CandidateRegisterDataa.candidateName
email = CandidateRegisterDataa.email
mobileNo = CandidateRegisterDataa.mobileNo
skill = CandidateRegisterDataa.skill
location = CandidateRegisterDataa.location
totalExp = CandidateRegisterDataa.totalExp
designation = CandidateRegisterDataa.designation
industry = CandidateRegisterDataa.industry
uploadResume = CandidateRegisterDataa.uploadResume
func checkCandidateNameErrors(name:String) -> Bool
let RegEx = "\A\w7,18\z"
let validator = NSPredicate(format:"SELF MATCHES %@", RegEx)
let valid = validator.evaluate(with: candidateName)
if !valid
errors.append("Invalid UserName")
return valid
func checkEmailErrors(email: String) -> Bool
let regex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]2,4"
let validator = NSPredicate(format: "SELF MATCHES %@", regex)
let valid = validator.evaluate(with: email);
if !valid
errors.append("Invalid Email")
return valid
func checkPhoneErrors(phoneNumber: String) -> Bool
let PHONE_REGEX = "^09[0-9'@s]9,9$"
let validator = NSPredicate(format: "SELF MATCHES %@", PHONE_REGEX)
let valid = validator.evaluate(with: mobileNo)
if !valid
errors.append("Invalid Password")
return valid
func checkPasswordErrors(password: String) -> Bool
let valid = !password.isEmpty && password.count >= 6
if !valid
errors.append("Invalid Password")
return valid
func cleanErrors()
errors.removeAll()
func showErrors()
let message = errors.joined(separator: ("n"))
let errorAlert = UIAlertController(title: "Erros", message: message, preferredStyle: .alert)
errorAlert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
context?.present(errorAlert, animated: true, completion: nil)
extension CandidateRegisterViewModel
func login_model( candidateName : String, email: String, password: String, mobileNo: String)
validation swift ios mvvm swift3
2
Hey, welcome to Code Review! You should add some description of what your code actually accomplishes. This should also be reflected in your title. Have a look at our help-center for some more tips on how to ask a good question here.
â Graipher
Jul 16 at 11:36
The site standard is for the title to simply state the task accomplished by the code, not your concerns about it. Please see How do I ask a good question? for examples, and revise the title accordingly.
â Martin R
Jul 16 at 12:24
add a comment |Â
up vote
0
down vote
favorite
1
up vote
0
down vote
favorite
1
1
I am new to MVVM. I Created Model class CandidateRegisterModel
and ViewModel class CandidateRegisterViewModel
class CandidateRegisterModel: NSObject
let viewModel = CandidateRegisterViewModel.self
var candidateName : String
var email : String
var mobileNo: Int
var skill : String
var location : String
var totalExp : Int
var designation : String
var industry : String
var uploadResume : String
init(candidateName: String, email: String, mobileNo: Int, skill: String, location: String, totalExp: Int, designation: String, industry: String , uploadResume: String)
self.candidateName = candidateName;
self.email = email;
self.mobileNo = mobileNo;
self.skill = skill;
self.location = location;
self.totalExp = totalExp;
self.designation = designation;
self.industry = industry;
self.uploadResume = uploadResume;
class CandidateRegisterViewModel
var CandidateRegisterData = CandidateRegisterModel?.self
var candidateName : String = ""
var email : String = ""
var mobileNo: Int? = nil
var skill : String = ""
var location : String = ""
var totalExp : Int? = nil
var designation : String = ""
var industry : String = ""
var uploadResume : String = ""
private var errors: [String] =
private weak var context: UIViewController?
init(controller: UIViewController)
context = controller
init(CandidateRegisterDataa : CandidateRegisterModel)
candidateName = CandidateRegisterDataa.candidateName
email = CandidateRegisterDataa.email
mobileNo = CandidateRegisterDataa.mobileNo
skill = CandidateRegisterDataa.skill
location = CandidateRegisterDataa.location
totalExp = CandidateRegisterDataa.totalExp
designation = CandidateRegisterDataa.designation
industry = CandidateRegisterDataa.industry
uploadResume = CandidateRegisterDataa.uploadResume
func checkCandidateNameErrors(name:String) -> Bool
let RegEx = "\A\w7,18\z"
let validator = NSPredicate(format:"SELF MATCHES %@", RegEx)
let valid = validator.evaluate(with: candidateName)
if !valid
errors.append("Invalid UserName")
return valid
func checkEmailErrors(email: String) -> Bool
let regex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]2,4"
let validator = NSPredicate(format: "SELF MATCHES %@", regex)
let valid = validator.evaluate(with: email);
if !valid
errors.append("Invalid Email")
return valid
func checkPhoneErrors(phoneNumber: String) -> Bool
let PHONE_REGEX = "^09[0-9'@s]9,9$"
let validator = NSPredicate(format: "SELF MATCHES %@", PHONE_REGEX)
let valid = validator.evaluate(with: mobileNo)
if !valid
errors.append("Invalid Password")
return valid
func checkPasswordErrors(password: String) -> Bool
let valid = !password.isEmpty && password.count >= 6
if !valid
errors.append("Invalid Password")
return valid
func cleanErrors()
errors.removeAll()
func showErrors()
let message = errors.joined(separator: ("n"))
let errorAlert = UIAlertController(title: "Erros", message: message, preferredStyle: .alert)
errorAlert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
context?.present(errorAlert, animated: true, completion: nil)
extension CandidateRegisterViewModel
func login_model( candidateName : String, email: String, password: String, mobileNo: String)
validation swift ios mvvm swift3
I am new to MVVM. I Created Model class CandidateRegisterModel
and ViewModel class CandidateRegisterViewModel
class CandidateRegisterModel: NSObject
let viewModel = CandidateRegisterViewModel.self
var candidateName : String
var email : String
var mobileNo: Int
var skill : String
var location : String
var totalExp : Int
var designation : String
var industry : String
var uploadResume : String
init(candidateName: String, email: String, mobileNo: Int, skill: String, location: String, totalExp: Int, designation: String, industry: String , uploadResume: String)
self.candidateName = candidateName;
self.email = email;
self.mobileNo = mobileNo;
self.skill = skill;
self.location = location;
self.totalExp = totalExp;
self.designation = designation;
self.industry = industry;
self.uploadResume = uploadResume;
class CandidateRegisterViewModel
var CandidateRegisterData = CandidateRegisterModel?.self
var candidateName : String = ""
var email : String = ""
var mobileNo: Int? = nil
var skill : String = ""
var location : String = ""
var totalExp : Int? = nil
var designation : String = ""
var industry : String = ""
var uploadResume : String = ""
private var errors: [String] =
private weak var context: UIViewController?
init(controller: UIViewController)
context = controller
init(CandidateRegisterDataa : CandidateRegisterModel)
candidateName = CandidateRegisterDataa.candidateName
email = CandidateRegisterDataa.email
mobileNo = CandidateRegisterDataa.mobileNo
skill = CandidateRegisterDataa.skill
location = CandidateRegisterDataa.location
totalExp = CandidateRegisterDataa.totalExp
designation = CandidateRegisterDataa.designation
industry = CandidateRegisterDataa.industry
uploadResume = CandidateRegisterDataa.uploadResume
func checkCandidateNameErrors(name:String) -> Bool
let RegEx = "\A\w7,18\z"
let validator = NSPredicate(format:"SELF MATCHES %@", RegEx)
let valid = validator.evaluate(with: candidateName)
if !valid
errors.append("Invalid UserName")
return valid
func checkEmailErrors(email: String) -> Bool
let regex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]2,4"
let validator = NSPredicate(format: "SELF MATCHES %@", regex)
let valid = validator.evaluate(with: email);
if !valid
errors.append("Invalid Email")
return valid
func checkPhoneErrors(phoneNumber: String) -> Bool
let PHONE_REGEX = "^09[0-9'@s]9,9$"
let validator = NSPredicate(format: "SELF MATCHES %@", PHONE_REGEX)
let valid = validator.evaluate(with: mobileNo)
if !valid
errors.append("Invalid Password")
return valid
func checkPasswordErrors(password: String) -> Bool
let valid = !password.isEmpty && password.count >= 6
if !valid
errors.append("Invalid Password")
return valid
func cleanErrors()
errors.removeAll()
func showErrors()
let message = errors.joined(separator: ("n"))
let errorAlert = UIAlertController(title: "Erros", message: message, preferredStyle: .alert)
errorAlert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
context?.present(errorAlert, animated: true, completion: nil)
extension CandidateRegisterViewModel
func login_model( candidateName : String, email: String, password: String, mobileNo: String)
validation swift ios mvvm swift3
edited Jul 16 at 13:30
200_success
123k14143399
123k14143399
asked Jul 16 at 11:12
Anshu
13
13
2
Hey, welcome to Code Review! You should add some description of what your code actually accomplishes. This should also be reflected in your title. Have a look at our help-center for some more tips on how to ask a good question here.
â Graipher
Jul 16 at 11:36
The site standard is for the title to simply state the task accomplished by the code, not your concerns about it. Please see How do I ask a good question? for examples, and revise the title accordingly.
â Martin R
Jul 16 at 12:24
add a comment |Â
2
Hey, welcome to Code Review! You should add some description of what your code actually accomplishes. This should also be reflected in your title. Have a look at our help-center for some more tips on how to ask a good question here.
â Graipher
Jul 16 at 11:36
The site standard is for the title to simply state the task accomplished by the code, not your concerns about it. Please see How do I ask a good question? for examples, and revise the title accordingly.
â Martin R
Jul 16 at 12:24
2
2
Hey, welcome to Code Review! You should add some description of what your code actually accomplishes. This should also be reflected in your title. Have a look at our help-center for some more tips on how to ask a good question here.
â Graipher
Jul 16 at 11:36
Hey, welcome to Code Review! You should add some description of what your code actually accomplishes. This should also be reflected in your title. Have a look at our help-center for some more tips on how to ask a good question here.
â Graipher
Jul 16 at 11:36
The site standard is for the title to simply state the task accomplished by the code, not your concerns about it. Please see How do I ask a good question? for examples, and revise the title accordingly.
â Martin R
Jul 16 at 12:24
The site standard is for the title to simply state the task accomplished by the code, not your concerns about it. Please see How do I ask a good question? for examples, and revise the title accordingly.
â Martin R
Jul 16 at 12:24
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Â
draft saved
draft discarded
Â
draft saved
draft discarded
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f199584%2fcandidate-registration-with-validation-using-mvvm%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
Hey, welcome to Code Review! You should add some description of what your code actually accomplishes. This should also be reflected in your title. Have a look at our help-center for some more tips on how to ask a good question here.
â Graipher
Jul 16 at 11:36
The site standard is for the title to simply state the task accomplished by the code, not your concerns about it. Please see How do I ask a good question? for examples, and revise the title accordingly.
â Martin R
Jul 16 at 12:24