Use factory methods to allow user to define validators.