Package-level declarations

Types

Link copied to clipboard
Link copied to clipboard
data class ErrorSafeValue<T>(val value: T, val initial: T = value, val error: String? = null)

Wraps a form field value together with its validation error and change-tracking state.

Link copied to clipboard
class FormValidator(val fields: List<validationField> = emptyList(), val flow: FormValidator.Flow = Down)
Link copied to clipboard
data class SnackBarProperties(val message: String? = null, val title: String = "Validation Error", val modifier: Modifier = Modifier.fillMaxWidth(), val margin: PaddingValues = PaddingValues(16.dp), val titleStyle: TextStyle? = null, val messageStyle: TextStyle? = null, val backgroundColor: Color? = null, val shape: Shape = RoundedCornerShape(8.dp), val visibleDuration: Duration = 3000.milliseconds, val enterTransition: EnterTransition = fadeIn() + expandIn(), val exitTransition: ExitTransition = shrinkOut() + fadeOut())

SnackBar properties for Form

Link copied to clipboard

Properties

Link copied to clipboard

Used to reference the validator in nested components. ``LocalFormValidator.current``

Functions

Link copied to clipboard

Creates a MutableState holding an ErrorSafeValue for value.

Link copied to clipboard
fun Form(modifier: Modifier = Modifier, validator: FormValidator = FormValidator(), snackBarProperties: SnackBarProperties = SnackBarProperties(), content: @Composable ColumnScope.() -> Unit = {})

Overload of Form that shows a snack bar with validation error. Suggestion -> When this overload is used, do not show the error for each field in the form with FormValidator.ValidationField.onError since the purpose of this form is to show one error at a time.

fun Form(modifier: Modifier = Modifier, validator: FormValidator = FormValidator(), verticalArrangement: Arrangement.Vertical = Arrangement.Top, horizontalAlignment: Alignment.Horizontal = Alignment.Start, content: @Composable ColumnScope.() -> Unit = {})