refractored validation