{"id":13610949,"url":"https://github.com/mustafayigitt/validator","last_synced_at":"2025-04-13T01:33:39.439Z","repository":{"id":42184609,"uuid":"497674773","full_name":"mustafayigitt/validator","owner":"mustafayigitt","description":"Notify type based validation for input fields.","archived":false,"fork":false,"pushed_at":"2023-08-04T14:01:49.000Z","size":128,"stargazers_count":58,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-08-01T19:56:04.770Z","etag":null,"topics":["android","android-validator","input-validation","kotlin","validation","validator"],"latest_commit_sha":null,"homepage":"https://blog.kotlin-academy.com/validator-rule-based-validation-library-in-android-2058e8d6c27","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mustafayigitt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2022-05-29T18:24:40.000Z","updated_at":"2023-08-29T11:45:04.000Z","dependencies_parsed_at":"2024-01-16T23:31:07.686Z","dependency_job_id":"25267fec-5b96-40dd-a646-a7c5961c6406","html_url":"https://github.com/mustafayigitt/validator","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustafayigitt%2Fvalidator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustafayigitt%2Fvalidator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustafayigitt%2Fvalidator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustafayigitt%2Fvalidator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mustafayigitt","download_url":"https://codeload.github.com/mustafayigitt/validator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223558421,"owners_count":17165127,"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","android-validator","input-validation","kotlin","validation","validator"],"created_at":"2024-08-01T19:01:49.850Z","updated_at":"2024-11-07T17:30:56.053Z","avatar_url":"https://github.com/mustafayigitt.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"\u003ch1 align=center\u003eValidator\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://jitpack.io/#mustafayigitt/validator\"\u003e\n    \u003cimg src=\"https://jitpack.io/v/mustafayigitt/validator.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://opensource.org/licenses/Apache-2.0\"\u003e\n    \u003cimg alt=\"License\" src=\"https://img.shields.io/badge/License-Apache%202.0-blue.svg\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://mustafayigitt.medium.com/validator-rule-based-validation-library-in-android-2058e8d6c27\"\u003e\n    \u003cimg alt=\"Medium\" src=\"https://skydoves.github.io/badges/Story-Medium.svg\"/\u003e\n  \u003c/a\u003e\n  \u003cp\u003e\n    Validate your inputs by \u003cstrong\u003enotify types\u003c/strong\u003e\n  \u003c/p\u003e \n\u003c/div\u003e\n\n\u003cp align=center\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/43048105/172043553-72a15316-f81d-496f-ad21-eccadc42c473.gif\" width=\"250\"\u003e\n\u003c/p\u003e\n\n## Import [![](https://jitpack.io/v/mustafayigitt/validator.svg)](https://jitpack.io/#mustafayigitt/validator)\n\n- **project level**\n````gradle\nallprojects {\n repositories {\n // ...\n   maven { url 'https://jitpack.io' }\n  }\n}\n````\n\n- **module level**\n````gradle\ndependencies {\n    implementation 'com.github.mustafayigitt:validator:Tag'\n}\n````\n\n## How to use\n\n````kotlin\n// Create a validator with Builder pattern\nval emailValidator = Validator.Builder()\n    .addRules(\n        ValidatableRule.Email(\"Enter valid mail address\"),\n        ValidatableRule.Required(\"Email is required\", NotifyType.ON_FOCUS_CHANGE),\n        ValidatableRule.Required(\"Email is required\", NotifyType.ON_FORM_SUBMIT),\n        ValidatableRule.Email(\"Enter valid mail address\", NotifyType.ON_FORM_SUBMIT),\n    )\n    .addCollector { validator -\u003e\n        mBinding.txtInputEmail.editText?.doOnTextChanged { text, _, _, _ -\u003e\n            validator.input = text.toString()\n        }\n        mBinding.txtInputEmail.editText?.setOnFocusChangeListener { _, isFocused -\u003e\n            validator.isFocused = isFocused\n        }\n    }\n    .onValidate { isValid, errorMessage, notifyType -\u003e\n        Log.d(\n            \"Validator\",\n            \"notifyType: $notifyType, isValid: $isValid, errorMessage: $errorMessage\"\n        )\n        mBinding.txtInputEmail.error = errorMessage\n    }\n    .build()\n````\n\n### Or you can write a custom ValidatableRule\n````kotlin\nclass PasswordConfirmRule(\n    override val errorMessage: String,\n    override val notifyType: NotifyType,\n    val originalInputGetter: () -\u003e String\n) : BaseValidatableRule(\n    errorMessage = errorMessage,\n    notifyType = notifyType,\n    rule = { it == originalInputGetter.invoke() }\n)\n\n// Usage\nval passwordConfirmValidator = Validator.Builder()\n    .addRules(\n        PasswordConfirmRule(\n            errorMessage = \"Passwords does not match\",\n            notifyType = NotifyType.ON_VALUE_CHANGE,\n            originalInputGetter = { mBinding.txtInputPassword.editText?.text.toString() },\n            )\n        )\n        ...\n````\n\n## License\n```xml\nCopyright 2022 mustafayigitt (Mustafa Yigit)\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmustafayigitt%2Fvalidator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmustafayigitt%2Fvalidator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmustafayigitt%2Fvalidator/lists"}