{"id":16213650,"url":"https://github.com/nwagu/forms","last_synced_at":"2025-03-19T09:31:04.739Z","repository":{"id":43999506,"uuid":"266970603","full_name":"nwagu/forms","owner":"nwagu","description":"A user input management library","archived":false,"fork":false,"pushed_at":"2024-05-08T14:08:51.000Z","size":462,"stargazers_count":20,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-28T17:46:56.886Z","etag":null,"topics":["android","forms","kotlin","kotlin-multiplatform","library","user-input","validation"],"latest_commit_sha":null,"homepage":"https://forms.nwagu.com","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nwagu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-26T07:11:23.000Z","updated_at":"2024-07-31T00:58:02.000Z","dependencies_parsed_at":"2024-10-27T20:29:31.715Z","dependency_job_id":"1d16f419-7c0e-46b0-892d-d5c932d9a20b","html_url":"https://github.com/nwagu/forms","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwagu%2Fforms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwagu%2Fforms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwagu%2Fforms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwagu%2Fforms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nwagu","download_url":"https://codeload.github.com/nwagu/forms/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243982141,"owners_count":20378605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","forms","kotlin","kotlin-multiplatform","library","user-input","validation"],"created_at":"2024-10-10T11:07:21.157Z","updated_at":"2025-03-19T09:31:04.094Z","avatar_url":"https://github.com/nwagu.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Maven Central](https://img.shields.io/maven-central/v/com.nwagu.forms/forms.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.nwagu.forms%22%20AND%20a:%22forms%22)\n\n## A form management library for Android\n\nThis simple library aims to add structure to the creation and management of forms on Android.\nFrom simple login forms to more complex forms that contain varying object types.\n\n## Usage\n\nAdd the dependency\n\n```groovy\ndependencies {\n    // ...\n    implementation \"com.nwagu.forms:forms:2.0.0-alpha09\"\n}\n```\n\nSee [sample activity](sampleAndroidApp/src/main/java/com/example/forms/MainActivity.kt) for usage\n\nCreate your form fields and add them to an instance of Form.\n\n```kotlin\nval form = Form(viewModelScope)\n\nval name = FormField\u003cString\u003e(required = true)\n        .apply {\n            addValidator { validateNotEmpty() }\n            addTo(form)\n        }\n\nval gender = FormField\u003cGender\u003e()\n        .apply {\n            addValidator { validateNonNullObject() }\n            addTo(form)\n        }\n```\n\nUpdate form\n```kotlin\nnameEdit.doOnTextChanged { text, start, count, after -\u003e\n    name.value = text?.toString()\n}\n```\n\nSet error reporting to begin on focus changed\n```kotlin\nnameEdit.setOnFocusChangeListener { v, hasFocus -\u003e\n    if (!hasFocus)\n        name.errorReportingEnabled = true\n}\n```\n\nForm fields expose observable feedback and error fields:\n```kotlin\nname.observe(\n    lifecycleScope,\n    onFeedback = {\n        // display helpful feedback\n    },\n    onError = {\n        nameEdit.error = it\n    },\n    onFocusRequest = {\n        // bring nameEdit to focus\n    }\n)\n```\n\n#### Tips\n1. You can define your custom validation functions. A few generic validators have been added to [FormFieldValidators](forms/src/commonMain/kotlin/com/nwagu/forms/FormFieldValidators.kt).\n2. Observe a form field's `focusRequest` to bring the view to focus when the form field has an error.\n\n## Note about multiplatform status\nYou can use this library now on Android or the JVM. I am currently trying it out on the other target platforms, especially iOS. \nThat's why it's still in alpha. \nIf you would like to use the older, stable, LiveData-based version of this library just for Android, please use version: `1.0.3`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnwagu%2Fforms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnwagu%2Fforms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnwagu%2Fforms/lists"}