validation and marshaling of structs/unions