moving per field validation logic into a separate function