Robustness of dynamical systems to a class of nonsmooth perturbations