{"action":"created","issue":{"url":"https://api.github.com/repos/TheJuki/KFormMaster/issues/52","repository_url":"https://api.github.com/repos/TheJuki/KFormMaster","labels_url":"https://api.github.com/repos/TheJuki/KFormMaster/issues/52/labels{/name}","comments_url":"https://api.github.com/repos/TheJuki/KFormMaster/issues/52/comments","events_url":"https://api.github.com/repos/TheJuki/KFormMaster/issues/52/events","html_url":"https://github.com/TheJuki/KFormMaster/issues/52","id":358336032,"node_id":"MDU6SXNzdWUzNTgzMzYwMzI=","number":52,"title":"Validation and Error examples","user":{"login":"josmas","id":194925,"node_id":"MDQ6VXNlcjE5NDkyNQ==","avatar_url":"https://avatars0.githubusercontent.com/u/194925?v=4","gravatar_id":"","url":"https://api.github.com/users/josmas","html_url":"https://github.com/josmas","followers_url":"https://api.github.com/users/josmas/followers","following_url":"https://api.github.com/users/josmas/following{/other_user}","gists_url":"https://api.github.com/users/josmas/gists{/gist_id}","starred_url":"https://api.github.com/users/josmas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josmas/subscriptions","organizations_url":"https://api.github.com/users/josmas/orgs","repos_url":"https://api.github.com/users/josmas/repos","events_url":"https://api.github.com/users/josmas/events{/privacy}","received_events_url":"https://api.github.com/users/josmas/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-09-08T23:39:26Z","updated_at":"2018-09-09T00:07:31Z","closed_at":"2018-09-09T00:07:31Z","author_association":"NONE","body":"## Description\r\n\r\nNot a bug as such, I believe I am just not using it correctly.\r\n### Expected behavior\r\nIf I have an element and a button like:\r\n```\r\n      text {\r\n        title = getString(R.string.city)\r\n        hint = \"city\"\r\n        required\r\n        maxLength = 2\r\n      }\r\n      button {\r\n        value = \"Submit\"\r\n        valueObservers.add { _, _ ->\r\n          if (formBuilder.getElementAtIndex(0).isValid) {\r\n            toast(\"form is valid!\")\r\n          }\r\n          else {\r\n            toast(\"form is not valid!\")\r\n          }\r\n        }\r\n      }\r\n```\r\nI would expect that the form is not valid if I type nothing in the text field. But it always goes through.\r\n`formBuilder.isValidForm` seems to also be always true.\r\n\r\nWith errors, when I have an element like this:\r\n```\r\n      text {\r\n        title = getString(R.string.city)\r\n        hint = \"city\"\r\n        error= \"This is the error message\"\r\n        required\r\n        maxLength = 2\r\n      }\r\n```\r\nI see the error message in red when the form loads, but after that, even if the field is changed and then emptied again, the error message goes away and never comes back.\r\n\r\nSo I believe I am doing something wrong, or not understanding how this works. I have tried using the values inside and outside of observers, but can't get any proper validation working.\r\n\r\nAny help would be greatly appreciated.\r\n\r\n### KFormMaster version\r\n\r\n* Version: 5.0.0\r\n\r\n### System information\r\n\r\n* Android OS: 8.1 on emulator\r\n* Issue in Emulator: Yes\r\n* Issue in physical device: Untested\r\n"},"comment":{"url":"https://api.github.com/repos/TheJuki/KFormMaster/issues/comments/419681204","html_url":"https://github.com/TheJuki/KFormMaster/issues/52#issuecomment-419681204","issue_url":"https://api.github.com/repos/TheJuki/KFormMaster/issues/52","id":419681204,"node_id":"MDEyOklzc3VlQ29tbWVudDQxOTY4MTIwNA==","user":{"login":"josmas","id":194925,"node_id":"MDQ6VXNlcjE5NDkyNQ==","avatar_url":"https://avatars0.githubusercontent.com/u/194925?v=4","gravatar_id":"","url":"https://api.github.com/users/josmas","html_url":"https://github.com/josmas","followers_url":"https://api.github.com/users/josmas/followers","following_url":"https://api.github.com/users/josmas/following{/other_user}","gists_url":"https://api.github.com/users/josmas/gists{/gist_id}","starred_url":"https://api.github.com/users/josmas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josmas/subscriptions","organizations_url":"https://api.github.com/users/josmas/orgs","repos_url":"https://api.github.com/users/josmas/repos","events_url":"https://api.github.com/users/josmas/events{/privacy}","received_events_url":"https://api.github.com/users/josmas/received_events","type":"User","site_admin":false},"created_at":"2018-09-09T00:07:31Z","updated_at":"2018-09-09T00:07:31Z","author_association":"NONE","body":"Hey @TheJuki thanks for the pointers. It was me being silly, as usual...\r\n\r\nIf you look at the code above I have:\r\n```\r\n  text {\r\n    required\r\n  }\r\n```\r\nInstead of:\r\n```\r\n  text {\r\n    required = true\r\n  }\r\n```\r\n\r\nFor some reason I thought it would override the default `false` value. So that is why it is always going through.\r\nNice to have the pointers to code anyway! :)\r\nI'll close this now."}}
{"actor":{"display_login":"josmas"}}