Skip to content

Instantly share code, notes, and snippets.

@asissuthar
Created November 7, 2022 06:01
Show Gist options
  • Save asissuthar/75e8b3b87c6a4bc4f3503461d3eca309 to your computer and use it in GitHub Desktop.
Save asissuthar/75e8b3b87c6a4bc4f3503461d3eca309 to your computer and use it in GitHub Desktop.
// ...
// Validate extention function for collection of FormFields. It will execute validate method of each field and return boolean result.
suspend fun Collection<FormField<*>>.validate(validateAll: Boolean = false) = coroutineScope {
if (validateAll) {
map { formField -> async { formField.validate(focusIfError = false) } }.awaitAll().all { result -> result }
} else {
all { formField -> formField.validate() }
}
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment