all I have a question how can I validate more then 10 values with arrow in kotlin.
fun CreateEventDTO.validate(): Validated<IncorrectInput, CreateEventDTO> =
name.isEventNameValid()
.zip(
about.isAboutValid(),
phone.isPhoneValid(),
price.isPriceValid(),
location.isLocationValid(),
startDate.isStartDateValid(),
// TODO add common validation for date
// endDate.isEndDateValid(),
status.isEventStatusValid(),
access.isEventAccessValid(),
category.isEventCategoryValid(),
musicStyles.isMusicStyleValid()
)
{ name, _, _, price, location, status, access, category, musicStyles ->
CreateEventDTO(
name = name,
about = about,
phone = phone,
price = price,
location = location,
startDate = startDate,
endDate = endDate,
status = status,
access = access,
category = category,
musicStyles = musicStyles
)
}
.mapLeft(ApiError::IncorrectInput)
If I will try to add one more validation then I will get an error because zip just allows up to 10values
Required:
Semigroup<TypeVariable(E)>
Found:
ValidatedNel<InvalidAbout, String?> /* = Validated<NonEmptyList<InvalidAbout>, String?> */
is there any other elegant ways to handle this?