Refactors loader directive and adds validation directive