refactoring: template validation unified