Skip to content
This repository was archived by the owner on Mar 16, 2025. It is now read-only.

Commit 70db321

Browse files
authored
Setup MkDocs (#42)
* doc : add kdoc to validables * doc : generate markdown with dokka * doc : add kdoc to validables * doc : generate markdown with dokka * doc : remove dokka * doc : remove dokka * doc : setup mkdocs * doc : (wip) cardscheme * mkdoc for all remaining validables * mkdoc site * remove the site folder * remove useless dokka files * fix detekt rule violation
1 parent 86678b7 commit 70db321

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+632
-51
lines changed

.github/workflows/Build.yaml renamed to .github/workflows/build.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build
1+
name: build
22

33
on:
44
push:

.github/workflows/doc.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: doc
2+
on:
3+
push:
4+
branches:
5+
- master
6+
permissions:
7+
contents: write
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Configure Git Credentials
14+
run: |
15+
git config user.name github-actions[bot]
16+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version: 3.x
20+
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
21+
- uses: actions/cache@v4
22+
with:
23+
key: mkdocs-material-${{ env.cache_id }}
24+
path: .cache
25+
restore-keys: |
26+
mkdocs-material-
27+
- run: pip install mkdocs-material
28+
- run: mkdocs gh-deploy --force

LICENSE

+10-18
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1-
MIT License
1+
Copyright 2024 Devscast
22

3-
Copyright (c) 2021 Devscast
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
46

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
7+
http://www.apache.org/licenses/LICENSE-2.0
118

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

detekt/config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,8 @@ style:
578578
value: 'FIXME:'
579579
- reason: 'Forbidden STOPSHIP todo marker in comment, please address the problem before shipping the code.'
580580
value: 'STOPSHIP:'
581-
- reason: 'Forbidden TODO todo marker in comment, please do the changes.'
582-
value: 'TODO:'
581+
# - reason: 'Forbidden TODO todo marker in comment, please do the changes.'
582+
# value: 'TODO:'
583583
allowedPatterns: ''
584584
ForbiddenImport:
585585
active: false

docs/coc.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level of experience,
9+
education, socio-economic status, nationality, personal appearance, race,
10+
religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at [email protected]. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org

docs/index.md

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Validable
2+
3+
![kotlin-version](https://img.shields.io/badge/kotlin-1.9.20-blue)
4+
[![](https://jitpack.io/v/devscast/validable.svg)](https://jitpack.io/#devscast/validable)
5+
[![Build](https://github.com/devscast/validable/actions/workflows/Build.yaml/badge.svg)](https://github.com/devscast/validable/actions/workflows/build.yaml)
6+
7+
Validating text fields when using jetpack compose can sometimes be challenging and verbose.
8+
9+
Validable is an extensible library that allows you to validate your text fields in a simpler way while having a reusable code.
10+
11+
```kotlin
12+
@Composable
13+
fun MyScreen() {
14+
15+
val emailField = remember { EmailValidable() }
16+
17+
TextField(
18+
value = emailField.value,
19+
onValueChange = { emailField.value = it }, // update the text
20+
isError = emailField.hasError(), // check if the field is not valid
21+
)
22+
23+
AnimatedVisibility(visible = emailField.hasError()) {
24+
25+
Text(
26+
text = emailField.errorMessage ?: "",
27+
modifier = Modifier.fillMaxWidth(),
28+
style = LocalTextStyle.current.copy(color = MaterialTheme.colors.error)
29+
)
30+
31+
}
32+
33+
Button(onClick = {
34+
// pass all fields to the withValidable method
35+
withValidable(emailField) {
36+
37+
// will be executed if all fields are valid
38+
Toast.makeText(context,"All fields are valid",Toast.LENGTH_SHORT).show()
39+
40+
}
41+
}) {
42+
Text(text = "Submit")
43+
}
44+
}
45+
```
46+
47+
## Installation
48+
49+
**Step 1.** Add the JitPack repository to your build file
50+
51+
Add it in your root build.gradle at the end of repositories:
52+
53+
```groovy
54+
allprojects {
55+
repositories {
56+
...
57+
maven { url 'https://jitpack.io' }
58+
}
59+
}
60+
```
61+
62+
**Step 2.** Add the dependency
63+
64+
```groovy
65+
dependencies {
66+
implementation 'com.github.devscast:validable:x.y.z'
67+
}
68+
```
69+
70+
License
71+
--------
72+
73+
Copyright 2024 Devscast Community.
74+
75+
Licensed under the Apache License, Version 2.0 (the "License");
76+
you may not use this file except in compliance with the License.
77+
You may obtain a copy of the License at
78+
79+
http://www.apache.org/licenses/LICENSE-2.0
80+
81+
Unless required by applicable law or agreed to in writing, software
82+
distributed under the License is distributed on an "AS IS" BASIS,
83+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
84+
See the License for the specific language governing permissions and
85+
limitations under the License.

docs/validables/cardscheme.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Validates that a card number belongs to a specified scheme.
2+
3+
```kotlin
4+
5+
// Validate if a text is a MasterCard number
6+
val cardField = CardSchemeValidable(
7+
CardScheme.MasterCard,
8+
"Only MasterCard is supported"
9+
)
10+
11+
// Supporting multiple cardScheme
12+
val multipleCardField = CardSchemeValidable(
13+
CardScheme.MasterCard,CardScheme.Visa,
14+
"Only MasterCard and Visa are supported"
15+
)
16+
17+
// Merging multiple CardSchemes into one
18+
val mixedCardScheme = CardScheme.merge(CardScheme.MasterCard, CardScheme.Visa)
19+
20+
val multipleCardField = CardSchemeValidable(
21+
mixedCardScheme,
22+
"Only MasterCard and Visa are supported"
23+
)
24+
```

docs/validables/email.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Validates that a value is a valid email address.
2+
3+
```kotlin
4+
val emailField = EmailValidable("invalid email")
5+
```

docs/validables/equal_to.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Validates that a value is equal to the specified value
2+
3+
```kotlin
4+
5+
val comparedValue = "Hello World"
6+
7+
val textField = EqualToValidable(
8+
comparedValue,
9+
"The value does not match $comparedValue"
10+
)
11+
```

docs/validables/greater_than.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Validates that a value is numerically greater than the specified value.
2+
3+
```kotlin
4+
val comparedValue = 10
5+
6+
val numberField = GreaterThanValidable(
7+
comparedValue,
8+
"The value must be > $comparedValue"
9+
)
10+
```
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Validates that a value is numerically greater than or equal to the specified value.
2+
3+
```kotlin
4+
val minAge = 18
5+
6+
val ageTextField = GreaterThanOrEqualValidable(
7+
minAge,
8+
"The minimum allowed age is $minAge"
9+
)
10+
```

docs/validables/host_name.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Validates that the given value is a valid host name
2+
3+
```kotlin
4+
val domainNameField = HostnameValidable(
5+
"Invalid domain name"
6+
)
7+
```
8+
9+
> According to [RFC 2606](https://www.rfc-editor.org/rfc/rfc2606.html), top-level domains (TLD) : `.example`, `.invalid`, `.localhost`, and `.test` are reserved
10+
and that's why hostnames containing them are not considered valid.

docs/validables/ip.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Validates that a value is a valid IP address
2+
3+
```kotlin
4+
val ipTextField = IpValidable("Not a valid IP address")
5+
```
6+
7+
> **Note** : Currently, IPv6 addresses are not supported.

docs/validables/less_than.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Validates that a value is numerically less than the specified value.
2+
3+
```kotlin
4+
val limit = 18
5+
6+
val numberTextField = LessThanValidable(
7+
limit,
8+
"The value must be < $limit"
9+
)
10+
11+
```

docs/validables/less_than_or_equal.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Validates that a value is numerically less than or equal to the specified value.
2+
3+
```kotlin
4+
val max = 9
5+
6+
val numberTextField = LessThanOrEqualValidable(
7+
max,
8+
"The value must be <= $max"
9+
)
10+
```

docs/validables/negative.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Validates that a value is a negative number.
2+
3+
```kotlin
4+
val numberField = NegativeValidable("The value must be < 0")
5+
```

docs/validables/negative_or_zero.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Validates that a value is a negative number or equal to zero.
2+
3+
```kotlin
4+
val numberField = NegativeOrZeroValidable("The value must be <= 0")
5+
```

docs/validables/not_blank.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Validates that the value is not blank - neither empty string nor whitespace are valid
2+
3+
```kotlin
4+
val textField = NotBlankValidable("This field cannot be blank")
5+
```

docs/validables/not_empty.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Validates that a value is not empty and contains some characters or whitespace characters.
2+
3+
```kotlin
4+
val textField = NotBlankValidable("This field cannot be blank")
5+
```

docs/validables/not_equal.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Validates that a value is not equal to the specified value
2+
3+
```kotlin
4+
val notAcceptedNumber = 7
5+
6+
val numberTextField = NotEqualToValidable(
7+
notAcceptedNumber,
8+
"The value must be different from $notAcceptedNumber"
9+
)
10+
```

0 commit comments

Comments
 (0)