diff --git a/README.md b/README.md index cbfe918..95a31b5 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,37 @@ public void createUser(NonBlankString name, PositiveInt age, NonEmptyList age = PositiveInt.of(18); +Validation name = NonBlankString.of("Ada"); +Validation> tags = + NonEmptyList.of(Arrays.asList("java", "fp")); // or List.of() on Java 9+ + +// combine results +Validation summary = + name.zip(age, (n, a) -> n.value() + " (" + a.value() + ")"); + +// unsafeOf() throws on invalid input — use at trusted boundaries +PositiveInt confirmedAge = PositiveInt.unsafeOf(18); +``` + ## Installation +> *"I can just implement this myself. Why add a dependency?"* +> +> Totally fair! Copy the source into your project — it's MIT licensed. +> But if it saved you some time... give me a ⭐ 🥺 + 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). ### Gradle Kotlin DSL @@ -60,30 +89,6 @@ dependencies { ``` -## Quick Start - -```java -import io.github.junggikim.refined.refined.numeric.PositiveInt; -import io.github.junggikim.refined.refined.string.NonBlankString; -import io.github.junggikim.refined.refined.collection.NonEmptyList; -import io.github.junggikim.refined.validation.Validation; -import io.github.junggikim.refined.violation.Violation; -import java.util.Arrays; - -// of() returns Validation — never throws -Validation age = PositiveInt.of(18); -Validation name = NonBlankString.of("Ada"); -Validation> tags = - NonEmptyList.of(Arrays.asList("java", "fp")); // or List.of() on Java 9+ - -// combine results -Validation summary = - name.zip(age, (n, a) -> n.value() + " (" + a.value() + ")"); - -// unsafeOf() throws on invalid input — use at trusted boundaries -PositiveInt confirmedAge = PositiveInt.unsafeOf(18); -``` - ## Kotlin Support Optional module with Kotlin-idiomatic extensions: