Function to perform validation on values