Skip to content

Commit 772bafd

Browse files
authored
Merge pull request #26 from JunggiKim/docs/readme-reorder-and-tone
docs: reorder Quick Start before Installation, add friendly tone
2 parents 192f17f + a454f06 commit 772bafd

1 file changed

Lines changed: 29 additions & 24 deletions

File tree

README.md

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,37 @@ public void createUser(NonBlankString name, PositiveInt age, NonEmptyList<String
3535

3636
Types replace scattered `if`-checks. Invalid data cannot even reach your method.
3737

38+
## Quick Start
39+
40+
```java
41+
import io.github.junggikim.refined.refined.numeric.PositiveInt;
42+
import io.github.junggikim.refined.refined.string.NonBlankString;
43+
import io.github.junggikim.refined.refined.collection.NonEmptyList;
44+
import io.github.junggikim.refined.validation.Validation;
45+
import io.github.junggikim.refined.violation.Violation;
46+
import java.util.Arrays;
47+
48+
// of() returns Validation — never throws
49+
Validation<Violation, PositiveInt> age = PositiveInt.of(18);
50+
Validation<Violation, NonBlankString> name = NonBlankString.of("Ada");
51+
Validation<Violation, NonEmptyList<String>> tags =
52+
NonEmptyList.of(Arrays.asList("java", "fp")); // or List.of() on Java 9+
53+
54+
// combine results
55+
Validation<Violation, String> summary =
56+
name.zip(age, (n, a) -> n.value() + " (" + a.value() + ")");
57+
58+
// unsafeOf() throws on invalid input — use at trusted boundaries
59+
PositiveInt confirmedAge = PositiveInt.unsafeOf(18);
60+
```
61+
3862
## Installation
3963

64+
> *"I can just implement this myself. Why add a dependency?"*
65+
>
66+
> Totally fair! Copy the source into your project — it's MIT licensed.
67+
> But if it saved you some time... give me a ⭐ 🥺
68+
4069
Published to [Maven Central](https://central.sonatype.com/artifact/io.github.junggikim/java-refined). Kotlin/JVM users can optionally add `java-refined-kotlin` for extension functions (adds `kotlin-stdlib` dependency).
4170

4271
### Gradle Kotlin DSL
@@ -60,30 +89,6 @@ dependencies {
6089
</dependency>
6190
```
6291

63-
## Quick Start
64-
65-
```java
66-
import io.github.junggikim.refined.refined.numeric.PositiveInt;
67-
import io.github.junggikim.refined.refined.string.NonBlankString;
68-
import io.github.junggikim.refined.refined.collection.NonEmptyList;
69-
import io.github.junggikim.refined.validation.Validation;
70-
import io.github.junggikim.refined.violation.Violation;
71-
import java.util.Arrays;
72-
73-
// of() returns Validation — never throws
74-
Validation<Violation, PositiveInt> age = PositiveInt.of(18);
75-
Validation<Violation, NonBlankString> name = NonBlankString.of("Ada");
76-
Validation<Violation, NonEmptyList<String>> tags =
77-
NonEmptyList.of(Arrays.asList("java", "fp")); // or List.of() on Java 9+
78-
79-
// combine results
80-
Validation<Violation, String> summary =
81-
name.zip(age, (n, a) -> n.value() + " (" + a.value() + ")");
82-
83-
// unsafeOf() throws on invalid input — use at trusted boundaries
84-
PositiveInt confirmedAge = PositiveInt.unsafeOf(18);
85-
```
86-
8792
## Kotlin Support
8893

8994
Optional module with Kotlin-idiomatic extensions:

0 commit comments

Comments
 (0)