diff --git a/api/konform.api b/api/konform.api index 2d880aa..f0ddaa0 100644 --- a/api/konform.api +++ b/api/konform.api @@ -53,8 +53,6 @@ public final class io/konform/validation/ValidationBuilder { public fun ()V public final fun addConstraint (Ljava/lang/String;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lio/konform/validation/Constraint; public final fun build ()Lio/konform/validation/Validation; - public final fun getHas (Lkotlin/reflect/KFunction;)Lio/konform/validation/ValidationBuilder; - public final fun getHas (Lkotlin/reflect/KProperty1;)Lio/konform/validation/ValidationBuilder; public final fun hint (Lio/konform/validation/Constraint;Ljava/lang/String;)Lio/konform/validation/Constraint; public final fun ifPresent (Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V public final fun ifPresent (Lkotlin/reflect/KFunction;Lkotlin/jvm/functions/Function1;)V diff --git a/src/commonMain/kotlin/io/konform/validation/ValidationBuilder.kt b/src/commonMain/kotlin/io/konform/validation/ValidationBuilder.kt index 67e37e4..a2ebd5c 100644 --- a/src/commonMain/kotlin/io/konform/validation/ValidationBuilder.kt +++ b/src/commonMain/kotlin/io/konform/validation/ValidationBuilder.kt @@ -165,11 +165,6 @@ public class ValidationBuilder { "'$name' is not a valid kotlin identifier or getter name." } - public val KProperty1.has: ValidationBuilder - get() = toPropKey(name, NonNull).getOrCreateBuilder() - public val KFunction1.has: ValidationBuilder - get() = toPropKey(name, NonNull).getOrCreateBuilder() - public inline fun ifInstanceOf(init: ValidationBuilder.() -> Unit): Unit = run(IsClassValidation(SubT::class, required = false, buildWithNew(init))) diff --git a/src/commonTest/kotlin/io/konform/validation/ValidationBuilderTest.kt b/src/commonTest/kotlin/io/konform/validation/ValidationBuilderTest.kt index bcccac2..64da890 100644 --- a/src/commonTest/kotlin/io/konform/validation/ValidationBuilderTest.kt +++ b/src/commonTest/kotlin/io/konform/validation/ValidationBuilderTest.kt @@ -167,26 +167,6 @@ class ValidationBuilderTest { "poweruser@".let { assertEquals(1, countErrors(nullableRequiredValidation(it))) } } - @Test - fun alternativeSyntax() { - val splitDoubleValidation = - Validation { - Register::password.has.minLength(1) - Register::password.has.maxLength(10) - Register::email.has.matches(".+@.+".toRegex()) - } - - Register(email = "tester@test.com", password = "a").let { assertEquals(Valid(it), splitDoubleValidation(it)) } - Register( - email = "tester@test.com", - password = "", - ).let { assertEquals(1, countErrors(splitDoubleValidation(it), Register::password)) } - Register(email = "tester@test.com", password = "aaaaaaaaaaa").let { - assertEquals(1, countErrors(splitDoubleValidation(it), Register::password)) - } - Register(email = "tester@").let { assertEquals(2, countFieldsWithErrors(splitDoubleValidation(it))) } - } - @Test fun functionAccessorSyntax() { val splitDoubleValidation = @@ -479,7 +459,9 @@ class ValidationBuilderTest { fun composeValidations() { val addressValidation = Validation
{ - Address::address.has.minLength(1) + Address::address { + minLength(1) + } } val validation = @@ -496,7 +478,9 @@ class ValidationBuilderTest { fun replacePlaceholderInString() { val validation = Validation { - Register::password.has.minLength(8) + Register::password { + minLength(8) + } } assertTrue(validation(Register(password = ""))[Register::password]!![0].contains("8")) }