Hello, I am working on a project where I need to ensure that some record that is optional in most cases, has a subset of those values populated in a specific instance. My thought was that there might be a way to cast an instance of the OptionalRecord into the RequiredRecord, and if successful you could return True, and if it fails then return False. I’m not sure how to write such a function, or if there is a better approach? There are 7-8 fields in my real records where I would like to use such a function, and on multiple different records so I do not want to manually check the fields, and so would like to make this function generic as well, where I can pass in a record type to try to cast the record instance into.
data OptionalRecord = OptionalRecord with
field1 : Optional Text
field2 : Optional Text
data RequiredRecord = RequiredRecord with
field1 : Text
field2 : Optional Text
ensureRecordHasRequiredFields : OptionalRecord -> Bool
ensureRecordHasRequiredFields recordInstance = do
???
???