{"id":3615,"url":"https://github.com/anderscheow/Validator","last_synced_at":"2025-08-03T20:32:49.903Z","repository":{"id":57732427,"uuid":"111089399","full_name":"anderscheow/Validator","owner":"anderscheow","description":"A tool to validate text inside TextInputLayout","archived":false,"fork":false,"pushed_at":"2021-10-10T14:12:09.000Z","size":387,"stargazers_count":127,"open_issues_count":1,"forks_count":12,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-06T11:04:17.999Z","etag":null,"topics":["android","android-library","edittext","textinputedittext","textinputlayout","validation","validator"],"latest_commit_sha":null,"homepage":"","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/anderscheow.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-17T10:14:54.000Z","updated_at":"2024-06-02T08:56:14.000Z","dependencies_parsed_at":"2022-09-10T20:31:14.291Z","dependency_job_id":null,"html_url":"https://github.com/anderscheow/Validator","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anderscheow%2FValidator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anderscheow%2FValidator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anderscheow%2FValidator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anderscheow%2FValidator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anderscheow","download_url":"https://codeload.github.com/anderscheow/Validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228461104,"owners_count":17923751,"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-library","edittext","textinputedittext","textinputlayout","validation","validator"],"created_at":"2024-01-05T20:16:46.481Z","updated_at":"2024-12-07T05:30:43.417Z","avatar_url":"https://github.com/anderscheow.png","language":"Kotlin","readme":"[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Validator-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/6478) [![](https://jitpack.io/v/anderscheow/Validator.svg)](https://jitpack.io/#anderscheow/Validator) \n[![codecov](https://codecov.io/gh/anderscheow/Validator/branch/master/graph/badge.svg)](https://codecov.io/gh/anderscheow/Validator/branch/develop)\n\n\n## Download\n```groovy\ndependencies {\n  implementation 'com.github.anderscheow:validator:3.0.3'\n}\n```\n\nUsage\n-----\n### Available rules\n\n* LengthRule\n* MaxRule\n* MinRule\n* NotEmptyRule\n* NotNullRule\n* RegexRule\n* AlphabetRule\n* AlphanumericRule\n* DigitsRule\n* EmailRule\n* PasswordRule\n* FutureRule\n* PastRule\n* CreditCardRule\n* ContainRule\n* NotContainRule\n* EqualRule\n* NotEqualRule\n* NotBlankRule\n* AllUpperCaseRule\n* AllLowerCaseRule\n* EndsWithRule\n* StartsWithRule\n* SymbolRule\n\n### Additional predefined rules to use in Validation or Condition\n\n* contain\n* notContain\n* notEqualTo\n* withinRange\n* minimumLength\n* maximumLength\n* email\n* alphanumericOnly\n* alphabetOnly\n* digitsOnly\n* symbolsOnly\n* allUppercase\n* allLowercase\n* startsWith\n* endsWith\n* withCreditCard\n* withPassword\n* notNull\n* notEmpty\n* notBlank\n* regex\n* future\n* past\n* matchAtLeastOneRule (Only for Validation)\n* matchAllRules (Only for Validation)\n\n### Beside from using the provided Rules, you can create your own Rule by extending Rule (Create as many as you want)\n\n```kotlin\nclass CustomRule : Rule(\"Value doesn't match 'ABC'\") {\n \n    override fun validate(value: String?): Boolean {\n        if (value == null) {\n            throw NullPointerException()\n        }\n        return value == \"ABC\"\n    }\n}\n```\n\n### Add it to your Activity class\n\n```kotlin\n// Username\n// Input: hello@test.com\nval usernameInput = findViewById(R.id.layout_username)\nval usernameValidation = validation(usernameInput) {\n    conditions {\n        +and(errorMessage = \"Does not match 'And' condition\") {\n            +email(errorMessage = \"\")\n            +endsWith(keyword = \".com\", errorMessage = \"\")\n        }\n        +or(errorMessage = \"Does not match 'Or' condition\") {\n            +minimumLength(minLength = 8, errorMessage = \"\")\n            +contain(keyword = \"hello\", errorMessage = \"\")\n        }\n    }\n}\n \n// Password\n// Input: 12345abc\nval passwordInput = findViewById(R.id.layout_password)\nval passwordValidation = validation(passwordInput) {\n    rules {\n        +notEmpty(errorMessage = \"Input is empty\")\n        +minimumLength(minLength = 8, errorMessage = \"Must have at least 8 characters\")\n    }\n}\n```\n\n### Mode\n\n```kotlin\nvalidator(applicationContext) {\n    /* Set your mode here, by default is CONTINUOUS */\n    mode = Mode.SINGLE\n}\n```\n\n| Single                                                          | Continuous                                                      |\n| ---                                                             | ---                                                             |\n| ![](https://media.giphy.com/media/3ohs7YJIZfbrC7txyU/giphy.gif) | ![](https://media.giphy.com/media/3ohs84PogwMOkUg0Jq/giphy.gif) |\n\n\n### Validate the input field\n\n```kotlin\n// Order of the values on the success callback follow the sequence of your Validation object\nvalidator(applicationContext) {\n    mode = Mode.SINGLE\n    listener = object : Validator.OnValidateListener {\n        override fun onValidateSuccess(values: List\u003cString\u003e) {\n            Log.d(\"MainActivity\", values.toTypedArray().contentToString())\n            Toast.makeText(\n                applicationContext,\n                \"Validate successfully\",\n                Toast.LENGTH_LONG\n            ).show()\n        }\n\n        override fun onValidateFailed(errors: List\u003cString\u003e) {\n            Log.e(\"MainActivity\", errors.toTypedArray().contentToString())\n        }\n    }\n    validate(usernameValidation, passwordValidation)\n}\n```\n\n* Introduce Validator library\n\n## Testing\nI have added unit testing for Rules and Conditions, soon will provide test code on Validation and Validator, please check it out under [Test code](https://github.com/anderscheow/Validator/tree/master/library/src/test/java/io/github/anderscheow/validator)\n\n## Contributions\nAny contribution is more than welcome! You can contribute through pull requests and issues on GitHub.\n\n## License\nValidator is released under the [MIT License](https://github.com/anderscheow/Validator/blob/master/LICENSE)","funding_links":[],"categories":["Libraries"],"sub_categories":["Utility"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanderscheow%2FValidator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanderscheow%2FValidator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanderscheow%2FValidator/lists"}