Hi,
I have a dto called UnvalidatedPerson that needs to be validated and turned into a valid ValidatedPerson value object:
class UnvalidatedPerson {
String id
String firstName
String lastName
String middleName
String address
... 7 more fields
}
class ValidatedPerson{
PersonId id
String firstName
String lastName
String middleName
Address address
... 7 more fields
}
I thought about using fj's Validation object for that: create Validation objects for all fields like ...
- Validation<Error, PersonId> idValidation
- Validation<Error, String> firstName
- Validation<Error, String> lastName
- ...
.. and finally accumulate them and return Validation<Error, ValidatedPerson> using some function F12<PersonId, String, String, ..., ValidatedPerson>
The problem is, there's more than 8 fields and the accumulate method that takes 8 validations maximum (and functions only go till F8).
How do you handle this - I assume - classic problem? Do you not have classes with more than 8 fields that need to be validated? Do you split them up into products? Am I not using Validation correctly?
Best regards
Jan