diff --git a/build.gradle.kts b/build.gradle.kts index 17835e9..31bfd13 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,6 +6,6 @@ plugins { } allprojects { - version = "0.4.0" + version = "0.3.3" group = "de.thetadev.formconductor" } diff --git a/compose-ui/src/main/java/de/thetadev/formconductor/composeui/scope/FormFieldScope.kt b/compose-ui/src/main/java/de/thetadev/formconductor/composeui/scope/FormFieldScope.kt index 934c656..ce49cb1 100644 --- a/compose-ui/src/main/java/de/thetadev/formconductor/composeui/scope/FormFieldScope.kt +++ b/compose-ui/src/main/java/de/thetadev/formconductor/composeui/scope/FormFieldScope.kt @@ -9,7 +9,7 @@ import de.thetadev.formconductor.FieldResult * * @param V type of field value */ -interface FormFieldScope { +interface FormFieldScope { /** * Observable State instance of field value @@ -30,19 +30,7 @@ interface FormFieldScope { * * You're encouraged to set the field value only using this function * - * @param input Field value - * @param validate Validate the input on update + * @param input input value */ fun setField(input: V?, validate: Boolean = true) - - /** - * A setter function for field value or error. - * - * Set the field value if the input is successful, fail validation if the input is an error. - * - * To be used for custom fields with built-in validation. - * - * @param input Field value or error - */ - fun setFieldResult(input: Result) } diff --git a/compose-ui/src/main/java/de/thetadev/formconductor/composeui/scope/FormFieldScopeImpl.kt b/compose-ui/src/main/java/de/thetadev/formconductor/composeui/scope/FormFieldScopeImpl.kt index fe196cf..2a1ab19 100644 --- a/compose-ui/src/main/java/de/thetadev/formconductor/composeui/scope/FormFieldScopeImpl.kt +++ b/compose-ui/src/main/java/de/thetadev/formconductor/composeui/scope/FormFieldScopeImpl.kt @@ -21,8 +21,4 @@ internal class FormFieldScopeImpl( override fun setField(input: V?, validate: Boolean) { formField.setField(input, validate) } - - override fun setFieldResult(input: Result) { - formField.setFieldResult(input) - } } diff --git a/core/src/main/java/de/thetadev/formconductor/FormField.kt b/core/src/main/java/de/thetadev/formconductor/FormField.kt index b944cb2..a26f211 100644 --- a/core/src/main/java/de/thetadev/formconductor/FormField.kt +++ b/core/src/main/java/de/thetadev/formconductor/FormField.kt @@ -50,22 +50,10 @@ interface FormField { * * The function validates the field if the input is not **empty** or the field isn't **optional** * - * @param input Field value - * @param validate Validate the input on update + * @param input */ fun setField(input: V?, validate: Boolean = true) - /** - * A setter function for field value or error. - * - * Set the field value if the input is successful, fail validation if the input is an error. - * - * To be used for custom fields with built-in validation. - * - * @param input Field value or error - */ - fun setFieldResult(input: Result) - /** * Validate the field without updating its value * diff --git a/core/src/main/java/de/thetadev/formconductor/FormFieldImpl.kt b/core/src/main/java/de/thetadev/formconductor/FormFieldImpl.kt index f9ac37c..1fe249b 100644 --- a/core/src/main/java/de/thetadev/formconductor/FormFieldImpl.kt +++ b/core/src/main/java/de/thetadev/formconductor/FormFieldImpl.kt @@ -1,7 +1,6 @@ package de.thetadev.formconductor import de.thetadev.formconductor.validation.optionalFlags.OptionalFlag -import de.thetadev.formconductor.validation.rules.ExternalValidationErrorRule import de.thetadev.formconductor.validation.rules.OptionalRule import de.thetadev.formconductor.validation.validators.FieldValidator import de.thetadev.formconductor.validation.validators.StatelessFieldValidator @@ -49,7 +48,6 @@ internal class FormFieldImpl( valueStream.value = input ?: defaultValue if (validate) { - if (hasExternalValidationError()) resultStream.value = FieldResult.NoInput validateField() } else if (input == null || input == "") { resultStream.value = FieldResult.NoInput @@ -58,23 +56,10 @@ internal class FormFieldImpl( } } - override fun setFieldResult(input: Result) { - input.fold( - onSuccess = { setField(it) }, - onFailure = { - resultStream.value = - FieldResult.Error("Validation error", ExternalValidationErrorRule) - } - ) - } - /** * Validates the current input value and updates the field's result */ override fun validateField(soft: Boolean) { - if (hasExternalValidationError()) { - return - } val input = valueStream.value // Null and empty strings are skipped for validation if (input != null && input != "") { @@ -125,9 +110,4 @@ internal class FormFieldImpl( optionalStateEvaluators.all(OptionalFlag::evaluate) } } - - private fun hasExternalValidationError(): Boolean { - val result = resultStream.value - return result is FieldResult.Error && result.failedRule is ExternalValidationErrorRule - } } diff --git a/core/src/main/java/de/thetadev/formconductor/validation/rules/ExternalValidationErrorRule.kt b/core/src/main/java/de/thetadev/formconductor/validation/rules/ExternalValidationErrorRule.kt deleted file mode 100644 index 117ce7e..0000000 --- a/core/src/main/java/de/thetadev/formconductor/validation/rules/ExternalValidationErrorRule.kt +++ /dev/null @@ -1,3 +0,0 @@ -package de.thetadev.formconductor.validation.rules - -object ExternalValidationErrorRule : ValidationRule diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 054c2d3..5ac0fad 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -agp = "9.4.1" +agp = "9.4.0" kotlinReflect = "1.7.10" kotlin = "2.4.10" kotlinxCoroutinesCore = "1.11.0"