Skip to content

Commit c295669

Browse files
authored
Merge pull request #18 from Kyash/readme
Created draft readme
2 parents d9394da + 3b538a3 commit c295669

File tree

29 files changed

+121
-39
lines changed

29 files changed

+121
-39
lines changed

README.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# ValidatableTextInputLayout
2+
3+
[![Build Status](https://circleci.com/gh/Kyash/validatable-textinput-layout.svg?style=shield)](https://circleci.com/gh/Kyash/validatable-textinput-layout/tree/master)
4+
[![JitPack](https://jitpack.io/v/Kyash/validatable-textinput-layout.svg)](https://jitpack.io/#Kyash/validatable-textinput-layout)
5+
6+
ValidatableTextInputLayout is the view which extended TextInputLayout to validate the input text easily for .
7+
8+
## Download
9+
10+
Project build.gradle
11+
12+
```groovy
13+
allprojects {
14+
repositories {
15+
...
16+
maven { url "https://jitpack.io" }
17+
}
18+
}
19+
```
20+
21+
App build.gradle
22+
23+
```groovy
24+
dependencies {
25+
...
26+
compile 'com.kyash.vtl:validatable-textinput-layout:LATEST_VERSION'
27+
}
28+
```
29+
30+
`LATEST_VERSION` is [![JitPack](https://jitpack.io/v/Kyash/validatable-textinput-layout.svg)](https://jitpack.io/#Kyash/validatable-textinput-layout)
31+
32+
## Basic usage
33+
You can use as same as `TextInputLayout` in layout xml.
34+
35+
### Layout
36+
`trigger` attribute defines the timing of the text field validation.
37+
38+
```xml
39+
<co.kyash.vtl.ValidatableTextInputLayout
40+
id="@id/first_name"
41+
android:layout_width="match_parent"
42+
android:layout_height="wrap_content"
43+
app:trigger="text_changed">
44+
45+
<EditText
46+
android:layout_width="match_parent"
47+
android:layout_height="wrap_content"
48+
android:hint="@string/first_name"
49+
android:inputType="textPersonName" />
50+
51+
</co.kyash.vtl.ValidatableTextInputLayout>
52+
```
53+
54+
### Kotlin
55+
Register Validator class to `ValidatableTextInputLayout`
56+
For example, `RequiredValidator` shows error when the field is empty.
57+
58+
```kotlin
59+
private fun initValidator() {
60+
binding.firstName.register(RequiredValidator(getString(R.string.validation_error_required)))
61+
}
62+
```
63+
64+
That's it. It works as below.
65+
66+
<img src="art/required_validator.gif" width="300">
67+
68+
## Triggers
69+
There are 2 types of the validation trigger attributes.
70+
71+
Attribute | Description
72+
:--: | :--
73+
text_changed | Validate immediately when the text is changed.
74+
focus_changed | Validate when the focus is changed
75+
76+
## Validators
77+
This library provides some common validators
78+
79+
Validator | Description
80+
:--: | :--
81+
RequiredValidator | Required validation
82+
EmailValidator | General Email address validation
83+
NumberOnlyValidator | Only numbers are permitted
84+
AsciiOnlyValidator | Only Ascii characters are permitted
85+
HiraganaOnlyValidator | Only Japanese Hiragana characters are permitted
86+
KatakanaOnlyValidator | Only Japanese Katakana characters are permitted
87+
88+
89+
90+
## Custom validator
91+
You can create the custom validator by using `VtlValidator`.
92+
Since `VtlValidator` uses RxJava2, it can handle async logic like API as well!
93+
94+
```
95+
96+
```
97+
98+
## Contributing
99+
We are always welcome your contribution!
100+
If you find a bug or want to add new feature, please raise issue.
101+
102+
## License
103+
104+
```
105+
Copyright 2018 Kyash
106+
107+
Licensed under the Apache License, Version 2.0 (the "License");
108+
you may not use this file except in compliance with the License.
109+
You may obtain a copy of the License at
110+
111+
http://www.apache.org/licenses/LICENSE-2.0
112+
113+
Unless required by applicable law or agreed to in writing, software
114+
distributed under the License is distributed on an "AS IS" BASIS,
115+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
116+
See the License for the specific language governing permissions and
117+
limitations under the License.
118+
```

art/email_validator.gif

88.8 KB
Loading
File renamed without changes.
File renamed without changes.

app/src/androidTest/java/co/kyash/vtl/MainActivityTest.kt renamed to example/src/androidTest/java/co/kyash/vtl/MainActivityTest.kt

File renamed without changes.

app/src/main/java/co/kyash/vtl/example/MainActivity.kt renamed to example/src/main/java/co/kyash/vtl/example/MainActivity.kt

File renamed without changes.

app/src/main/res/drawable/ic_launcher_background.xml renamed to example/src/main/res/drawable/ic_launcher_background.xml

File renamed without changes.

app/src/main/res/layout/activity_main.xml renamed to example/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,9 @@
128128

129129
</android.support.v7.widget.CardView>
130130

131-
<View
132-
android:layout_width="match_parent"
133-
android:layout_height="1dp"
134-
android:layout_marginBottom="@dimen/space_16dp"
135-
android:layout_marginTop="@dimen/space_16dp"
136-
android:background="@color/grey500" />
137-
138131
<TextView
139132
style="@style/Title"
133+
android:layout_marginTop="@dimen/space_32dp"
140134
android:text="@string/trigger_focus_change" />
141135

142136
<android.support.v7.widget.CardView

0 commit comments

Comments
 (0)