{"id":20774243,"url":"https://github.com/pchmn/androidverify","last_synced_at":"2025-07-18T15:34:49.967Z","repository":{"id":117650232,"uuid":"86321843","full_name":"pchmn/AndroidVerify","owner":"pchmn","description":"Android library designed for rapid and customizable form validation.","archived":false,"fork":false,"pushed_at":"2017-04-18T07:14:18.000Z","size":1547,"stargazers_count":40,"open_issues_count":0,"forks_count":11,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-30T15:18:11.684Z","etag":null,"topics":["android-library","easy-to-use","form-validation","java"],"latest_commit_sha":null,"homepage":null,"language":"Java","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/pchmn.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-27T10:23:05.000Z","updated_at":"2023-09-08T17:22:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"4f744a71-0fa3-4b5c-bef5-3d3652d1824f","html_url":"https://github.com/pchmn/AndroidVerify","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/pchmn/AndroidVerify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchmn%2FAndroidVerify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchmn%2FAndroidVerify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchmn%2FAndroidVerify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchmn%2FAndroidVerify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pchmn","download_url":"https://codeload.github.com/pchmn/AndroidVerify/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchmn%2FAndroidVerify/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265786687,"owners_count":23828315,"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-library","easy-to-use","form-validation","java"],"created_at":"2024-11-17T12:28:52.063Z","updated_at":"2025-07-18T15:34:49.947Z","avatar_url":"https://github.com/pchmn.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AndroidVerify\n\nAndroid library designed for rapid and customizable form validation.\n\n[![Release](https://jitpack.io/v/pchmn/AndroidVerify.svg)](https://jitpack.io/#pchmn/AndroidVerify)\n\n## Demo\n[Download sample-v1.0.2.apk](https://github.com/pchmn/AndroidVerify/raw/master/docs/android-verify-v1.0.2.apk)\n\n## Setup\n\nTo use this library your `minSdkVersion` must be \u003e= 15.\n\nIn your project level build.gradle :\n```java\nallprojects {\n    repositories {\n        ...\n        maven { url \"https://jitpack.io\" }\n    }\n}       \n```\n\nIn your app level build.gradle :\n```java\ndependencies {\n    compile 'com.github.pchmn:AndroidVerify:1.0.2'\n}      \n```\n\n## Usage\n\nYou can use **AndroidVerify** with any `View` that extends the original [`EditText`](https://developer.android.com/reference/android/widget/EditText.html) (such as \n[`MaterialEditText`](https://github.com/rengwuxian/MaterialEditText) for example).\n\n### With XML\n\nYou just have to wrap your `EditText` with an `InputValidator` view. Example for an email and a custom regex :\n\n```xml\n\u003ccom.pchmn.androidverify.InputValidator\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    app:required=\"true\"\n    app:requiredMessage=\"Email required\"\u003e\n\n    \u003cEditText\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:inputType=\"textEmailAddress\"\n        android:hint=\"Email\"/\u003e\n\n\u003c/com.pchmn.androidverify.InputValidator\u003e\n            \n\u003ccom.pchmn.androidverify.InputValidator\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    app:regex=\"^[0-9]{4}$\"\n    app:errorMessage=\"4 digits only\"\u003e\n\n    \u003cEditText\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:hint=\"Regex 4 digits (custom error msg)\"/\u003e\n\n\u003c/com.pchmn.androidverify.InputValidator\u003e            \n```\n`InputValidator` will automatically recognized **textEmailAdress**, **phone** and **number** `inputType` and use the appropriate validator, like in the example with the email field.\n\u003cbr\u003eIf you don't specify an `errorMessage` or a `requiredMessage`, predefined messages will be shown if the field is not valid.\n\nThen **validate** your form :\n```java\n// initiate from an activity\n// 'this' represents an Activity\n// you can specify if you want to show error messages or not\nForm form = new Form.Builder(this)\n    .showErrors(true)\n    .build();\n\n// or initiate from a fragment or from what you want by providing your own root view\nForm form = new Form.Builder(getContext(), rootView)\n    .showErrors(true)\n    .build();\n\n// validate the form\nif(form.isValid()) {\n    // the form is valid\n}\nelse {\n    // the form is not valid\n}        \n```\n\n### With Java\n\nYou can create programmatically `InputValidator` without passing by XML ([see all Builder methods](#inputvalidator-builder)) :\n\n```java\n// create the validator with the Builder\n// emailEditText is the EditText to validate \n// 'this' represents a Context\nInputValidator emailValidator = new InputValidator.Builder(this)\n    .on(emailEditText)\n    .required(true)\n    .validatorType(InputValidator.IS_EMAIL)\n    .build();\n                \n// create the form and add the validator\nForm form = new Form.Builder(this)\n    .addInputValidator(emailValidator)\n    .build();\n    \n// validate the form\nif(form.isValid()) {\n    // the form is valid\n}\nelse {\n    // the form is not valid\n}\n```\n\nYou can create programmatically without using the Builders, but it is safer and quicker to use Builders.\n\n### Attributes\n\n#### `InputValidator`\nAll the attributes that can be used with the `InputValidator` view. They can be used in XML or in Java with setters :\n\nAttribute | Type | Description\n--- | --- | ---\n`app:required` | `boolean` | Whether the field is required or not\n`app:validator` | `enum` | Use a validator type predefined by FormValidator. You can use **isEmail**, **isPhoneNumber**, **isNumeric**, **isUrl** or **isIP**\n`app:minLength` | `int` | The minimum length of the field\n`app:maxLength` | `int` | The maximum length of the field\n`app:minValue` | `int` | The minimum value of the field (must be numeric)\n`app:maxValue` | `int` | The maximum value of the field (must be numeric)\n`app:regex` | `string` | Use a regex to validate a field\n`app:identicalAs` | `reference id` | The id of an EditText to which the field must be equal\n`app:errorMessage` | `string` | The message to display if the field is not valid\n`app:requiredMessage` | `string` | The message to display if the field is empty but was required. It implies that the field is required\n\n#### `Form`\nAll the attributes that can be used with the `Form` view. They can be used in XML or in Java with setters :\n\nAttribute | Type | Default | Description\n--- | --- | --- | ---\n`app:showErrors` | `boolean` | `true` | Whether the errors must be shown on each EditText or not\n\n\n## Advanced Usage\n\n### Use a custom validator\n\nYou can use a custom validator for an `InputValidator` : \n```java\n// the InputValidator was present in the XML layout\nInputValidator inputValidator = (InputValidator) findViewById(R.id.input_validator);\n// your custom validator must extends AbstractValidator class\ninputValidator.setCustomValidator(new AbstractValidator() {\n    @Override\n    public boolean isValid(String value) {\n        return value.equals(\"ok man\");\n    }\n              \n    @Override\n    public String getErrorMessage() {\n        return \"This field must be equals to 'ok man'\";\n    }\n});\n\n\n// or create your InputValidator with the Builder\nInputValidator inputValidator = new InputValidator.Builder(this)\n    .on(anEditText)\n    .customValidator(new AbstractValidator() {\n        @Override\n        public boolean isValid(String value) {\n            return value.equals(\"ok man\");\n        }\n                  \n        @Override\n        public String getErrorMessage() {\n            return \"This field must be equals to 'ok man'\";\n        }\n    });\n    .build();\n```\n\n\n### Use the `Form` view in XML\n\nIf you want, you can use a `Form` view directly in XML. This view extends [`LinearLayout`](https://developer.android.com/reference/android/widget/LinearLayout.html). It must wrap all the fields you want to check.\n\nIt can be useful for these reasons : \n* You don't have to instantiate a `Form` object before validate the form\n* It will be easier to identify a form in your XML layout\n* You can use two different and independent forms in the same XML layout\n\n#### XML\n```xml\n    \u003c!-- form1 --\u003e\n    \u003ccom.pchmn.androidverify.Form\n        android:id=\"@+id/form1\"\n        android:orientation=\"vertical\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        app:showErrors=\"false\"\u003e\n\n        \u003c!-- email --\u003e\n        \u003ccom.pchmn.androidverify.InputValidator\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\u003e\n\n            \u003cEditText\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"wrap_content\"\n                android:inputType=\"textEmailAddress\"\n                android:hint=\"Email\"/\u003e\n\n        \u003c/com.pchmn.androidverify.InputValidator\u003e\n\n        \u003c!-- password --\u003e\n        \u003ccom.pchmn.androidverify.InputValidator\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            app:required=\"true\"\n            app:minLength=\"6\"\u003e\n\n            \u003cEditText\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"wrap_content\"\n                android:inputType=\"textPassword\"\n                android:hint=\"Password (6 char. min) *\" /\u003e\n\n        \u003c/com.pchmn.androidverify.InputValidator\u003e\n\n    \u003c/com.pchmn.androidverify.Form\u003e\n    \u003c!-- /form1 --\u003e\n\n    \u003c!-- form2 --\u003e\n    \u003ccom.pchmn.androidverify.Form\n        android:id=\"@+id/form2\"\n        android:orientation=\"vertical\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\u003e\n\n        \u003c!-- phone number --\u003e\n        \u003ccom.pchmn.androidverify.InputValidator\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            app:required=\"true\"\u003e\n\n            \u003cEditText\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"wrap_content\"\n                android:inputType=\"phone\"\n                android:hint=\"Phone number *\"/\u003e\n\n        \u003c/com.pchmn.androidverify.InputValidator\u003e\n\n        \u003c!-- age --\u003e\n        \u003ccom.pchmn.androidverify.InputValidator\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            app:minValue=\"12\"\u003e\n\n            \u003cEditText\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"wrap_content\"\n                android:inputType=\"number\"\n                android:hint=\"Age (12 min)\" /\u003e\n\n        \u003c/com.pchmn.androidverify.InputValidator\u003e\n\n    \u003c/com.pchmn.androidverify.Form\u003e\n    \u003c!-- /form2 --\u003e\n```\n\n#### Validate the forms\n\n```java\n// get the forms\n// you don't have to instantiate them because they already know the fields they have to validate\nForm form1 = (Form) findViewById(R.id.form1);\nForm form2 = (Form) findViewById(R.id.form2);\n\n// validate form1\nif(form1.isValid()) {\n    // form1 is valid\n}\n\n// validate form2\nif(form2.isValid()) {\n    // form2 is valid\n}\n\n```\n\n\n### Builders method\n\nIt is recommended to use the builders to create `Form` and `InputValidator` views programmatically in order to prevent some errors. All the attributes for the two views are supported by the builders.\n \n#### `InputValidator` builder\n\n```java\nInputValidator inputValidator = new InputValidator.Builder(this)\n    // methods\n    .build();\n```\n\n\nMethod | Return value | Description\n--- | --- | ---\n`InputValidator.Builder(Context context)` | `InputValidator.Builder` | The constructor of the builder\n`on(EditText editText)` | `InputValidator.Builder` | The EditText to validate\n`required(boolean required)` | `InputValidator.Builder` | Whether the field is required or not\n`validatorType(int type)` | `InputValidator.Builder` | Use a validator type predefined by FormValidator. You can use **InputValidator.IS_EMAIL**, **InputValidator.IS_PHONE_NUMBER**, **InputValidator.IS_NUMERIC**, **InputValidator.IS_URL** or **InputValidator.IS_IP**\n`customValidator(AbstractValidator validator)` | `InputValidator.Builder` | Use a custom validator\n`minLength(int length)` | `InputValidator.Builder` | The minimum length of the field\n`maxLength(int length)` | `InputValidator.Builder` | The maximum length of the field\n`minValue(int value)` | `InputValidator.Builder` | The minimum value of the field (must be numeric)\n`maxValue(int value)` | `InputValidator.Builder` | The maximum value of the field (must be numeric)\n`regex(String regex)` | `InputValidator.Builder` | Use a regex to validate a field\n`identicalAs(int id)` | `InputValidator.Builder` | The id of an EditText to which the field must be equal\n`identicalAs`(EditText editText)` | `InputValidator.Builder` | An other EditText to which the field must be equal\n`errorMessage(String message)` | `InputValidator.Builder` | The message to display if the field is not valid\n`requiredMessage(String message)` | `InputValidator.Builder` | The message to display if the field is empty but was required\n`build()` | `InputValidator` | Create the `InputValidator` object\n\n#### `Form` builder\n\n```java\nForm form = new Form.Builder(this)\n    // methods\n    .build();\n```\n\nMethod | Return value | Description\n--- | --- | ---\n`Form.Builder(Activity activity)` | `Form.Builder` | First constructor of the builder\n`Form.Builder**(Context context, View rootView)` | `Form.Builder` | Second constructor of the builder\n`Form.Builder(Context context)` | `Form.Builder` | Third constructor of the builder. Be aware of possibly inflating errors using this constructor\n`addInputValidator(InputValidator validator)` | `Form.Builder` | Add an `InputValidator`\n`showErrors(boolean show)` | `Form.Builder` | Whether the errors must be shown on each EditText or not\n`build()` | `Form` | Create the `Form` object\n\n## Sample\n\nA sample app with some use cases of the library is available on this [link](https://github.com/pchmn/FormValidator/tree/master/sample)\n\n## Credits\n\n* [Ratifier](https://github.com/hamadakram/ratifier?utm_source=android-arsenal.com\u0026utm_medium=referral\u0026utm_campaign=5441)\n* [Android-Validator](https://github.com/throrin19/Android-Validator)\n\n## License\n\n```\nCopyright 2017 pchmn\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\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpchmn%2Fandroidverify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpchmn%2Fandroidverify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpchmn%2Fandroidverify/lists"}