Reducing duplicate code between min and max validators