I will need to validate records before storing them in a database. Does something exist already to do that? (I didn’t find anything)
My current preference is to keep the record type as is, and apply a validation to it (contrary to this).
If I need to develop it myself, I’m looking for advice on how to structure my code. Here are the ideas to come to mind:
- define a record with similar field names but the types of the fields would be
('a -> bool) listwhile the data record filed would be of type
'a. Validation would be checking that all functions return true for each field. Downside is that it requires an additional type for each record, and I’m not sure if traversing record fields is easy.
- define a list of tuples
(fieldname:string) * ( ('a->bool) list). One type is defined for validation of all records. But will be manipulating a tuple list easy for error extraction?
Maybe a bool returning function is not fine to get error messages, and the validation function should return a
Would anonymous record be handy regarding the first idea?
Thanks in advance for your ideas