dave08
12/25/2023, 10:39 AMValidator { } that generates a Raise<NonEmptySet<ConstraintViolation>>.() -> T that way it could be used in an either without toEither() and bind(..)?Johann Pardanaud
12/25/2023, 2:45 PMdave08
12/25/2023, 2:56 PMRaise<NonEmptySet<ConstraintViolation>>.() -> T where T is the entity being validated...Johann Pardanaud
01/02/2024, 8:53 AMValidator { } variant for Arrow, because it will create a new declaration with a weird name like ArrowValidator and it would also duplicate the interface by changing its return types.
The idea suggested by Alejandro seems to be a better fit: the validate function keeps the same name, regardless of the context (within a Raise computation or not) ; and the interface doesn't change since it returns the same type but the validate function does the work to bind the value to the Raise computation.dave08
01/02/2024, 10:26 AMJohann Pardanaud
01/02/2024, 10:36 AMJohann Pardanaud
01/02/2024, 10:37 AMbut I can't help thinking how ValidationResult is really just a simplified Either type...you're right, but not everyone uses Arrow, I don't want Akkurate to have a hard dependance on it
dave08
01/02/2024, 10:39 AMval validatedUsername = validate(username) {
isNotBlank()
}
doesn't create a validator that can be reused to validate multiple times like the main api, but rather validates on the spot?Johann Pardanaud
01/02/2024, 10:40 AMJohann Pardanaud
01/02/2024, 10:40 AMdave08
01/02/2024, 10:41 AMval usernameValidator = validate(username) {
isNotBlank()
}
... either {
val username = usernameValidator(...)
...
}dave08
01/02/2024, 10:41 AMJohann Pardanaud
01/02/2024, 10:42 AMJohann Pardanaud
01/02/2024, 10:42 AM