While some platform in some languages already address this issue, I would like to keep this semi-language agnostic and to focus on patterns associated with this issue.
I have a data model that contains FirstName, MiddleName, and LastName (to keep things simple). First and Last names are required and may have other rules to ensure their validity. Middle name is optional.
By default, the model is empty and thus, invalid.
When a value changes, an event can be triggered to validate the field that changed.
My question is what patterns can be used to best manage the state of the object since, based on the scenario, I'm doing field level validation. Should I move to model level validation on field change which would address the state issue or is there an alternate way?