Skip to content

Commit

Permalink
fix problem validation1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
rigo9412 committed Feb 7, 2019
1 parent 0c0bdd1 commit 1804604
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ class MainActivity : AppCompatActivity() {
setContentView(R.layout.activity_main)

btnForm.setOnClickListener {
val field1 = FieldImage(arrayListOf("nombre"),"Nombre*",true,"Campo requerido", TypeField.SELECT_IMAGE)
val field2 = FieldText(arrayListOf("hora"),"Hora de entrega*",true, TypeField.TEXT_HOURS,"Campo requerido")
//val field1 = FieldImage(arrayListOf("nombre"),"Nombre*",false,"Campo requerido", TypeField.SELECT_IMAGE)
val field2 = FieldText(arrayListOf("hora"),"Hora de entrega*",false, TypeField.TEXT_HOURS,"Campo requerido")
val fieldTipoFlotilla = FieldOptions(arrayListOf("tipoFlotilla"),"Tipo flotilla",TypeField.SELECT_OPTION,
arrayListOf("1","2","3"), arrayListOf())


val field3 = FieldText(arrayListOf("apellido_paterno"),"Apellido Paterno*",true, TypeField.TEXT,"Campo requerido",140)
val field32 = FieldText(arrayListOf("apellido_paterno"),"Apellido Paterno*",true, TypeField.TEXT,"Campo requerido",140)
//val field3 = Field(arrayListOf("apellido_materno"),"Apellido Materno*",true, TypeField.TEXT,"Campo requerido",140)
val form = Form("1","Informacion Personal", arrayListOf(field1,field2,fieldTipoFlotilla,field3,field32))
val form = Form("1","Informacion Personal", arrayListOf(field2,fieldTipoFlotilla,field3))


val i = Intent(this, FormsActivity::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,15 @@ open class FieldText() : Field(){
return true

return when(type){
TypeField.TEXT-> !(value?.get(0)!!.isNotEmpty())
TypeField.TEXT_EMAIL-> !(value?.get(0)!!.isNotEmpty())&& isEmailValid(value?.get(0)!!)
TypeField.TEXT-> (value?.get(0)!!.isNotEmpty())
TypeField.TEXT_EMAIL-> (value?.get(0)!!.isNotEmpty())&& isEmailValid(value?.get(0)!!)
TypeField.TEXT_PASSWORD-> !(value?.get(0)!!.isNotEmpty()) && isValidPassword(value?.get(0)!!)
TypeField.TEXT_NUM-> !(value?.get(0)!!.isNotEmpty())
TypeField.TEXT_HOURS-> !(value?.get(0)!!.isNotEmpty())
TypeField.TEXT_DEC-> !(value?.get(0)!!.isNotEmpty())
TypeField.TEXT_PHONE-> !(value?.get(0)!!.isNotEmpty())
TypeField.TEXT_CURP-> !((value?.get(0)!!.isNotEmpty()) && isValidCURP(value?.get(0)!!))
TypeField.TEXT_RFC-> !((value?.get(0)!!.isNotEmpty()) && isValidRFC(value?.get(0)!!))
TypeField.TEXT_NUM-> (value?.get(0)!!.isNotEmpty())
TypeField.TEXT_HOURS-> (value?.get(0)!!.isNotEmpty())
TypeField.TEXT_DEC-> (value?.get(0)!!.isNotEmpty())
TypeField.TEXT_PHONE-> (value?.get(0)!!.isNotEmpty())
TypeField.TEXT_CURP-> ((value?.get(0)!!.isNotEmpty()) && isValidCURP(value?.get(0)!!))
TypeField.TEXT_RFC-> ((value?.get(0)!!.isNotEmpty()) && isValidRFC(value?.get(0)!!))
else -> {
return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class FormFragment : Fragment() {
TypeField.TEXT_PHONE, TypeField.TEXT_PASSWORD, TypeField.TEXT_DATE,TypeField.TEXT_RFC,TypeField.TEXT_CURP -> {
if (view is TextInputLayout) {
form!!.fields[index].value?.add(0,view.editText?.text.toString())
if (form!!.fields[index].isValid()) {
if (!form!!.fields[index].isValid()) {
view.error = form!!.fields[index].errorMessage
isValid = false
}else{
Expand Down

0 comments on commit 1804604

Please sign in to comment.