Refactored validation directives to place repeated code into separate functions