Validate total_length and set error when invalid