
Simplifies text field validation by providing reusable validators for form inputs, supporting severity levels for validation messages and customizable user interaction behavior.
TextField validation is a pain, hopefully this is a bit easier
val emailValidator = rememberTextFieldValueValidator(
rules = listOf(Required, Email)
)
with(emailValidator) {
OutlinedTextField(
value = value,
onValueChange = ::onValueChange,
modifier = Modifier
.validationConfig(
// will start validation on loss of focus
validateOnFocusLost = true,
// will shake the field when invalid and validate() is called
shakeOnInvalid = true,
// when false will delay [isError] until validate() is called
showErrorOnInteraction = false,
)
.fillMaxWidth(),
label = { Text("Email*") },
placeholder = { Text("Email") },
leadingIcon = { Icon(Icons.Default.Email, contentDescription = "Email") },
isError = isError(), // will mark the field error when validation has started and is invalid
supportingText = supportingText(), // will show the validation message, or error message
)
}TextFieldValueValidator - a validator for TextFieldValue that can be used with TextField and OutlinedTextField
GenericValueValidator - a generic validator that can be used to validate any type
TextFields!ValueValidatorRules to make putting forms together easierOutcome - Supports different levels of severity for validation messages, Error, Warning, Info, Success
ValidationConfig - Allows you to configure how the validation should behave to user interactionBy default we publish to Maven Central.
We publish all targets (Android, JVM, JS, Wasm, iOS) you can include the common library in your project and it will pull in the correct target for what ever targets you have specified.
commonMain {
dependencies {
implementation("com.chrisjenx.yakcov:library:${version}")
}
}If you only need a specific target you can include that directly, for example for Android:
dependencies {
implementation("com.chrisjenx.yakcov:library-android:${version}")
}Yakcov's phone-number validation rules uses luca992 port of libphonenumber. The Yakcov library declares this as compileOnly, so if you plan to use any phone-number validation rules you must add the dependency yourself in your app or shared module.
Kotlin Multiplatform (recommended):
commonMain {
dependencies {
implementation("io.github.luca992.libphonenumber-kotlin:libphonenumber:0.1.8")
}
}./gradlew :library:allTests
TextField validation is a pain, hopefully this is a bit easier
val emailValidator = rememberTextFieldValueValidator(
rules = listOf(Required, Email)
)
with(emailValidator) {
OutlinedTextField(
value = value,
onValueChange = ::onValueChange,
modifier = Modifier
.validationConfig(
// will start validation on loss of focus
validateOnFocusLost = true,
// will shake the field when invalid and validate() is called
shakeOnInvalid = true,
// when false will delay [isError] until validate() is called
showErrorOnInteraction = false,
)
.fillMaxWidth(),
label = { Text("Email*") },
placeholder = { Text("Email") },
leadingIcon = { Icon(Icons.Default.Email, contentDescription = "Email") },
isError = isError(), // will mark the field error when validation has started and is invalid
supportingText = supportingText(), // will show the validation message, or error message
)
}TextFieldValueValidator - a validator for TextFieldValue that can be used with TextField and OutlinedTextField
GenericValueValidator - a generic validator that can be used to validate any type
TextFields!ValueValidatorRules to make putting forms together easierOutcome - Supports different levels of severity for validation messages, Error, Warning, Info, Success
ValidationConfig - Allows you to configure how the validation should behave to user interactionBy default we publish to Maven Central.
We publish all targets (Android, JVM, JS, Wasm, iOS) you can include the common library in your project and it will pull in the correct target for what ever targets you have specified.
commonMain {
dependencies {
implementation("com.chrisjenx.yakcov:library:${version}")
}
}If you only need a specific target you can include that directly, for example for Android:
dependencies {
implementation("com.chrisjenx.yakcov:library-android:${version}")
}Yakcov's phone-number validation rules uses luca992 port of libphonenumber. The Yakcov library declares this as compileOnly, so if you plan to use any phone-number validation rules you must add the dependency yourself in your app or shared module.
Kotlin Multiplatform (recommended):
commonMain {
dependencies {
implementation("io.github.luca992.libphonenumber-kotlin:libphonenumber:0.1.8")
}
}./gradlew :library:allTests