Factored out common code in the validation error directives