I would create a Worker
data class with the fields listed in Item
column as properties and some boolean properties representing validity of those fields.
data class Worker(val name:String, val gender :String, val age :Int, val tel:String,val email:String){
var isNameValid : Boolean = false
get(){
return name.isNotEmpty()
}
var isGenderValid : Boolean = false
get(){
return gender.equals("Male",true) || gender.equals("Female",true)
}
var isAgeValid : Boolean = false
get(){
return age >= 18 && age<=60
}
var isTelValid : Boolean = false
get(){
//TODO : validate telephone number
return true
}
var isEmailValid: Boolean = false
get(){
//TODO: validate email.
return true
}
}
You can create Worker
objects and use them as elements of an Worker
array/list.
val workerA = Worker("A", "Male", 18, "123", "a@mail.com")
val workerB = Worker("B", "Female", 20, "122", "b@mail.com")
val workers: List<Worker> = listOf(workerA, workerB)
println(workers[0].isNameValid)
As your question does not provide the validation rules for fields and the table provided does not make it obvious, I have left implementation of getters up to you. Check the questions linked below.
How should I validate an e-mail address?
Email and phone Number Validation in android